Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Running A Excel Macro From VBScript

Can anyone help with this ?

I am trying to Run a Macro in my Excel Sheet using VBScript So Far I have tried the Following

'This is a VBScript.
Dim strPath
Dim oXLA

strPath = "MyExcel.xls!CreateData"

set oXLA = CreateObject("Excel.Application")

oXLA.Run strPath

Set oXLA = Nothing
This is no good. I tried some Solution I found after doing a Google Search those did not Help Also.
Please point me in correct direction.


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Openning Excel And Running Macro From Word - Macro
Ok - I have a DB which I export to Excel, I then run a macro to "Groom The Data". I then run word and run a Macro (MailMerge to print labels) which retrieves data from the excel spreadsheet groomed above. Everything is working fine, despite my novice knowledge of VB, but I would like to do this in a single click.

I use a command line shortcut to Launch word and automatically have it run the macro, but I still have to Launch Excel and manually run its macro first.

I did not find a command line switch to make excel launch and run a macro. Is there any way I can Lauch Word have its Macro link to excel, then launch and run the excel macros before performing the macro I have set up in word (mailmerge)

In Other Words I have working macros in Word and Excel, I want the Word Macro to force the Excel macro to run before completing the rest of its duties.


Vbscript And Asp To Run Excel Macro

I'm trying to get an asp page to run a macro on an excel 2000 file. Here is my code:

dim objExcel, objWorkbook

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open("C:Macro05.xls")"Macro1()")

set objWorkbook = nothing
set objExcel = nothing
Here is the error message I'm getting :
Microsoft Excel (0x800A03EC)
The macro 'Macro1()' cannot be found.
/directory/macrotest06.asp, line 9

[VBScript] Excel Macro: Split String In Cells?
I have a list of names [First Last] in a column of Excel cells (A1 through A340 or so). The person who did the data entry was silly enough to put both first and last name in the same cell... it fell on me to write a script that would split them. Too bad I know no VBA, only VB.NET...

Example: Cell A1 has "John Smith". The macro needs to split it into A1 "John" and A2 "Smith", or A2 and A3, or whatever.

From VB experience, I know I should use a For loop to step through the string until I find a space, then chop and move... but can someone help me with appropriate commands for a VBScript macro?


Using Excel While Macro Is Running
Hi.... I have a timed process that runs every half hour. Using Doevents in a do while loop I can continue to enter data on the worksheet. However, as soon as I try to do anything in another worksheet the macro stops. Any ideas how I can run a automatic timed macro and still use the other sheets in the workbook......THanks

For i = n To x

dtEnd = timestodo(i, 1)
Do While dtEnd > Now()
If Range("A1") > 0 Then GoTo finishmacro

newdata = Range("B1:CZ1")

Range("B181:CZ181") = newdata

Running An Excel Macro From Within VB
Hi all,
I need to run a silly little macro from a command button in VB.

This is the macro from excel:

Sub Macro1()
' Macro1 Macro
' Macro recorded 21/01/2002 by MAGrosoft
' Keyboard Shortcut: Ctrl+q
Workbooks.Open Filename:="C:My DocumentsBook2.xls"
End Sub

its just a cut and paste thingy.
what I want is to be able to call that macro from VB
Any suggestions as to how I do that?
could I dim variabvles in this macro (VBA) so that I can change the selections and filenames, and then pass the parameters from VB across to the VBA macro?

Thanks in advance

Running Excel Macro
How can I call an Excel macro and pass a parameter to it from my vb code? I used
Set ApExcel = CreateObject("Excel.sheet")
ApExcel.Application.Run "PERSONAL.xls!getStats"
but how can I change the code to pass in a parameter?

Running Excel Macro From Word
i have 2 macros, one in word, which manipulates the document and saves the file as an excel file on my desktop, and another macro in excel which manipulates the data and saves it as a file with no extension.

i for the word macro to run the excel macro after it is finished. i have tried several things but it doesnt seem to work, (i do have the references set properly to accept excel commands)

can anyone help with the code to complete this??

any help would be greatly appreciated

Running An Access Macro From Excel
I have a macro set up in Access which merges various excel spreadsheets . What I want to do is include the right VB code in my excel macro so that once it has finished with the spreadsheet it automatically opens access and runs the macro in there....can this be done ??

Excel Event Macro's Not Running
Anyone know what would cause my event macros to stop running. It seems like they work for a few minutes then quit. I put a break in the code and the macro window doesn't pop up. Any ideas??

Running An Access Macro In Excel
I'm trying to run an Access Macro (Macro1) using the Visual Basic Editor in Excel. The code i'm using is:

Sub RunAccMacro()
Dim oAccess As Object, oDB As Object
Set oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase "J:UPSUPS.mdb"
oAccess.Run "Macro1"
End Sub

This opens the Access Database ok but then I get the runtime error:

Run-time error '2517':
Microsoft Access can't find the procedure 'Macro1.'

Any ideas why this is happening?


EXCEL - How To Prevent A Macro From Running
I'm writing this macro to open a number of Excel workbooks and copy some rows to a Word document.

Everything works fine but for two glitches:

1) After copying a row containing a large amount of text, Excel prompts me to either clear the ClipBoard or keep its contents when it tries to close the workbook, though it is supposed to be hidden. Can this check be turned off before closing a workbook?

2) Some of the workbooks I'm processing have a Workbook_Open macro attached to them that in turn refers to an external .xls. Is it possible to prevent this macro from running?
Edit by Moderator:
Please post Excel questions in the Excel board.

Thank you.

Refreshing Excel While Running A Macro!?!?

I've created a macro for excel which communicates with a database server called Proserver. This server can relay data from 2 PLC's to a PC. The macro collects data from the PLC's via this server and displays it in Excel. This works fine except for one thing: the PLC's store a huge amount of data and therfore collecting the data needs a reasonably amount of time. During this time several processes can't take place. Therefor I divided the data in 10 blocks and send 1 block at a time. My problem is that when I receive the 10 blocks, in between two blocks I want to write and refresh the data of the last received block on my Excelscreen. However I can't get it working. When I place a breakpoint in my macro at the point where it's ready to receive the next block, it works. My Excel screen is refreshed and the data is displayed. When I step over the breakpoint, the next block is displayed. But without the breakpoint it just rumbles through the macro untill all blocks are received and then the screen is refreshed. And I need the screen to be refreshed afther every received block. It seems to me that during macro runtime Excel itself hangs.
I tried the refresh commando but it won't work. Can anyone help me?
Thanks in advance,


Running A Macro Upon Opening Excel
I have a macro written in an excel workbook and I want to know how I can make it run automatically whenever the file is opened without having to run it manually. Any help is appreciated.

Running A Form From A Macro In Excel
Hi there, a simple one from Simple Si...

I have a button on an Excel sheet and when I press the button it runs a macro.
What do I enter in to the macro code to get it to run a form?

I have tried Run frmForm1() but it keeps telling me that I have the wrong number of arguments (I have not specified any arguments in the code for the form though).


Opening EXCEL Using VB6 Without Running Macro
Hello, I wonder if anyone out there can help me.

I am writing an application in VB6 to open an Excel spreadsheet created by another user. When Excel opens the spreadsheet it runs a macro which puts a dialog box on screen which prevents users accessing the information in the cells of the worksheets. If the user does a CTRL + Break, the spreadsheet goes into debug mode and they can then access the cells directly.

Is there a way to open the spreadsheet using VB6 without the macro running?

Running An Excel Macro From Another Workbook
Got a problem... is it possible to run a macro in some workbook from another workbook (both of them are open)? I have created a custom menu item, but it applies only to the workbook by which it was created - so when I close that WB I need to "recreate" the menu item from workbook #2 in case it is open.

Any ideas? Thanx in advance.

Running Macro When Opening Excel File
I've recorded a macro and saved it in the workbook.
When I or some other user opens this file, I want the macro to run automatically. How do I do that?


Help Saving Excel Workbook After Running Macro

I am writing a VB6 program and part of it involves opening a .DAT document in excel and running a macro(that generates graphs) on it, then saving the document as an excel workbook in a particular folder.

Here is my code:

Dim xl As Excel.Application
Dim macroBook As Excel.Workbook 'contains necessary macro
Dim book2 As Excel.Workbook 'run macro on this work book

Set xl = New Excel.Application
xl.Visible = True
Set macroBook = xl.Workbooks.Open("C:Documents and SettingspeevpMy DocumentsWeather Data 2006CMHC EXCEL FILESM02 2006 4 29.xls")

Set book2 = xl.Workbooks.Open("C:Documents and SettingspeevpMy DocumentsWeather Data 2006CMHC 2006_05_28 to 2006_06_03M02 2006 6 3.dat")

xl.Run "'M02 2006 4 29.xls'!Graph_Data" 'run the macro

book2.SaveAs "C:Documents and SettingspeevpMy DocumentsWeather Data 2006 est.xls" 'save it as "test.xls"
book2.Saved = True


Set book2 = Nothing


Set xl = Nothing
The problem is that the saved new workbook file, "test.xls," does not display the graphs that were generated by the Macro program. The "test.xls" file is simply the same as the .DAT file, as if I had never run the macro on it in the first place.

When i step through the program line by line, after the save as method the excel file has been renamed to "test.xls" and the graphs show up in the workbook. But when the program quits and i open the excel file, there are no graphs.

Any suggestions, this has been frustrating me for abit.


Edit by Moderator:
Please use the [vb][/vb] when you post your code. Edit or reply to this post to see how.

Thank you.

Date Formats In Excel After Running Macro
Dear All

I have developed some code which takes data from a spreadsheet, formats it and saves it as a csv file.

I have hit a problem with the date format. The output comes back as excel time stamps rather than date and time formats (dd/mm/yy hh:mm:ss).

I have tried several methods of using some formatting to change but it does seem to work. Could someone suggest a change? Code posted below

Dim Obj1 As Object
Dim Obj2 As Object
Dim UserList()
Sub RunMe()
Dim Str1 As String
Dim myPath As String
Dim i As Integer
Set Obj1 = CreateObject("excel.application")

myPath = "C:Test" 'please note you should a "" at the end.

Str1 = Dir(myPath & "*.xls")
Set Obj2 = CreateObject("excel.application")
Obj1.Application.DisplayAlerts = False
Obj1.Workbooks.Open (myPath & Str1)
'For i = 1 To UBound(userslist)
'If Obj1.ActiveWorkbook.BuiltinDocumentProperties("Author").Value = userslist(i) Then
Call Macro1Bis 'or do whatever you want with the file
' Exit For
'End If
Obj1.Application.DisplayAlerts = True
Str1 = Dir()
Loop Until Str1 = ""
Set Obj1 = Nothing
Set Obj2 = Nothing
End Sub
Sub Macro1Bis()
Dim a
Dim Str1 As String
Dim Str2 As String
With Obj1.ActiveWorkbook.ActiveSheet
.Range(.Cells(2, 15), .Cells(2, 5).End(-4121).End(-4161).Offset(0, 2)).FormulaR1C1 = "=RC[-10]+RC[-9]"
.Range(.Cells(2, 16), .Cells(2, 15).End(-4121).Offset(0, 1)).FormulaR1C1 = "=RC[-7]"
a = .Range(.Cells(2, 15), .Cells(2, 16).End(-4121))
End With
With Obj2.ActiveWorkbook.ActiveSheet
.Range(.Cells(6, 1), .Cells(5 + UBound(a), UBound(a, 2))) = a
.Cells(5, 1) = "Time"
.Cells(5, 2) = Obj1.ActiveWorkbook.ActiveSheet.Cells(2, 3)
Select Case UCase(.Cells(5, 2))
Case "PRESSURE": Str1 = "01"
Case "FLOW": Str1 = "02"
Case "LEVEL PERCENT": Str1 = "03"
End Select
.Cells(5, 3) = Obj1.ActiveWorkbook.ActiveSheet.Cells(2, 4)
.Cells(2, 1) = "Site Name"
.Cells(2, 2) = Obj1.ActiveWorkbook.ActiveSheet.Cells(2, 1) & "_" & Obj1.ActiveWorkbook.ActiveSheet.Cells(2, 2) & "_" & Str1
Str2 = .Cells(2, 2)
Obj2.Application.DisplayAlerts = False
Obj2.ActiveWorkbook.SaveAs Filename:="C:Test" & Str2, FileFormat:=xlCSV, CreateBackup:=False
End With
Obj2.Application.DisplayAlerts = True
End Sub

VBA - Running A Macro At Worksheet Load In Excel
I have an Excel 2002 spreadsheet that does some automatic calculations when the user clicks on the command button. I would like the spreadsheet to run a particular macro when it first loads.

I've tried putting code in Worksheet_Activate, but of course that doesn't run until the user selects the sheet. I don't want the user to have to do anything, I just want it to run automatically.

Any suggestions? Thanks in advance.

Auto Running A Macro When Excel Opens
I would like to have a macro run in an Excel spreadsheet when the spreadsheet is opened.

Does anyone know how to get a macro to run on the spreadsheet open event?

How To Display A Message While Running A VB Macro In Excel?
I have a macro which processes a list of files and creates a report. How do I display a message which shows the name of the file the macro is currently processing?
I don't want to stop the macro by using msgbox which requires user interaction.


Edited by - sdunin on 7/9/2007 10:51:07 AM

Running An Excel Macro On Multiple Worksheets
I have the following macro:

Code:Sub PSAPerfBreak2Macro()
' PSAPerfBreak2Macro Macro
' Macro recorded 9/11/2003 by VJ Occhino
Dim rval As String
Dim nval As String
Dim rng1 As String
Dim rng2 As String
Dim finr As String

   nval = ActiveCell.Value
   rval = InputBox("Enter text to replace:")
   finr = "g1:g500,n1:n500"
   If rval = "" Then
    MsgBox ("Canceled")
   Selection.Replace What:=rval, Replacement:=nval, LookAt:=xlPart, _
   SearchOrder:=xlByColumns, MatchCase:=False
   End If
End Sub

Currently, it updates the two ranges on the ACTIVE worksheet that I define in my variable "Finr". However, I would like the same "find & replace" macro to work in another range in another worksheet in the same workbook. Is there a way to define my finr as not just"g1:g500,n1:n500" in the current worksheet but a range in another worksheet as well?

Thanks in advance!!!

Running Excel Macro From Visual C++ Application
I have a Visual C++ application from where i want
to start an excel macro.

The excel macro will be one i would have recorded using

Is their any sample code or reference where i can look up
how to do this ?

Any assistance in solving my problem would be appreciated.


Riaz Awan

Access 2003 Opening Excel File And Not Running Workbook_open Macro How?
Using code below I am opening various spreadsheets and running multiple routines.

Dim objFileSystem As Object
Dim objFolder As Object
Dim objFilesCol As Object
Dim objFile As Object
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSystem.GetFolder(DtR)
Set objFilesCol = objFolder.Files
For Each objFile In objFilesCol
xLs.Workbooks.Open DtR & objFile.Name
xLs.Run "'" & objFile.Name & "'!all"
xLs.ActiveWorkbook.Close savechanges:=False
Set objFileSystem = Nothing
Set objFolder = Nothing
Set objFilesCol = Nothing
Set objFile = Nothing
One of the spreadsheets is doing:

Workbooks.Open Filename:=EXTERNALSPREADSHEET, ReadOnly:=True, Origin:=xlWindows
This EXTERNALSPREADSHEET sometimes contains workbook_open macro.
How can I prevent this macro from running?

Can You Get An Access Macro To Include Running An XL Macro
Is it possible to have an MS access run its own "thing" and in the middle of it all call on excel to run it owns macro?

How To Use Macro(VBscript?) To Save A Doc??
I want to know is there any way to use macro to store a winword document?
Let say i have a winword document called testing.doc which is just finished editing in the winword, how can i store this document into hardisk and close this document by using macro??

How To Get Vbscript Running
I had the following VBscript code below, but I cannot get it to work in a web page. It had to do with formating correctly with HTML code. I am new to VBscript.

Enabling Internet Connection Firewall (VBScript)
The following VBScript code first determines if Internet Connection Sharing and Internet Connection Firewall are available on the local computer. If so, the code enumerates the connections on the local computer, and enables Internet Connection Firewall on the connection that is specified as a command line argument.




DIM NetSharingManager
DIM PublicConnection, PrivateConnection
DIM EveryConnectionCollection

DIM objArgs
DIM con


Main( )

sub Main( )
Set objArgs = WScript.Arguments

if objArgs.Count = 1 then
con = objArgs(0)

WScript.Echo con

if Initialize() = TRUE then

end if
DIM szMsg
szMsg = "Invalid usage! Please provide the name of the connection as the argument." & chr(13) & chr(13) & _
"Usage:" & chr(13) & _
" " + WScript.scriptname + " " + chr(34) + "Connection Name" + chr(34)
WScript.Echo( szMsg )
end if

end sub

sub FirewallTestByName(conName)
on error resume next
DIM Item
DIM EveryConnection
DIM objNCProps
DIM szMsg
DIM bFound

bFound = false
for each Item in EveryConnectionCollection
set EveryConnection = NetSharingManager.INetSharingConfigurationForINetConnection(Item)
set objNCProps = NetSharingManager.NetConnectionProps(Item)
if (ucase(conName) = ucase(objNCProps.Name)) then
szMsg = "Enabling Firwall on connection:" & chr(13) & _
"Name: " & objNCProps.Name & chr(13) & _
"Guid: " & objNCProps.Guid & chr(13) & _
"DeviceName: " & objNCProps.DeviceName & chr(13) & _
"Status: " & objNCProps.Status & chr(13) & _
"MediaType: " & objNCProps.MediaType

bFound = true
exit for
end if

if( bFound = false ) then
WScript.Echo( "Connection " & chr(34) & conName & chr(34) & " was not found" )
end if

end sub

function Initialize()
DIM bReturn
bReturn = FALSE

set NetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
if (IsObject(NetSharingManager)) = FALSE then
Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object")
if (IsNull(NetSharingManager.SharingInstalled) = TRUE) then
Wscript.Echo("Sharing isn't available on this platform.")
bReturn = TRUE
end if
end if
Initialize = bReturn
end function

function GetConnectionObjects()
DIM bReturn
DIM Item

bReturn = TRUE

if GetConnection(CONNECTION_PUBLIC) = FALSE then
bReturn = FALSE
end if

if GetConnection(CONNECTION_PRIVATE) = FALSE then
bReturn = FALSE
end if

if GetConnection(CONNECTION_ALL) = FALSE then
bReturn = FALSE
end if

GetConnectionObjects = bReturn

end function

function GetConnection(CONNECTION_TYPE)
DIM bReturn
DIM Connection
DIM Item
bReturn = TRUE

set Connection = NetSharingManager.EnumPublicConnections(ICSSC_DEFAULT)
if (Connection.Count > 0) and (Connection.Count < 2) then
for each Item in Connection
set PublicConnection = NetSharingManager.INetSharingConfigurationForINetConnection(Item)
bReturn = FALSE
end if
set Connection = NetSharingManager.EnumPrivateConnections(ICSSC_DEFAULT)
if (Connection.Count > 0) and (Connection.Count < 2) then
for each Item in Connection
set PrivateConnection = NetSharingManager.INetSharingConfigurationForINetConnection(Item)
bReturn = FALSE
end if
set Connection = NetSharingManager.EnumEveryConnection
if (Connection.Count > 0) then
set EveryConnectionCollection = Connection
bReturn = FALSE
end if
bReturn = FALSE
end if

if (TRUE = bReturn) then

if (Connection.Count = 0) then
Wscript.Echo("No " + CStr(ConvertConnectionTypeToString(CONNECTION_TYPE)) + " connections exist (Connection.Count gave us 0)")
bReturn = FALSE
'valid to have more than 1 connection returned from EnumEveryConnection
elseif (Connection.Count > 1) and (CONNECTION_ALL <> CONNECTION_TYPE) then
Wscript.Echo("ERROR: There was more than one " + ConvertConnectionTypeToString(CONNECTION_TYPE) + " connection (" + CStr(Connection.Count) + ")")
bReturn = FALSE
end if
end if
Wscript.Echo(CStr(Connection.Count) + " objects for connection type " + ConvertConnectionTypeToString(CONNECTION_TYPE))

GetConnection = bReturn
end function

function ConvertConnectionTypeToString(ConnectionID)
DIM ConnectionString

if (ConnectionID = CONNECTION_PUBLIC) then
ConnectionString = "public"
elseif (ConnectionID = CONNECTION_PRIVATE) then
ConnectionString = "private"
elseif (ConnectionID = CONNECTION_ALL) then
ConnectionString = "all"
ConnectionString = "Unknown: " + CStr(ConnectionID)
end if

ConvertConnectionTypeToString = ConnectionString
end function

Running Vbscript
can i run a vbscript inside a vb application? how? can you teach me? thanks!

Word Macro + Find/Replace + VBScript
Below is the code that i wrote to open a file, find some text, replace it and save the file under a different name, however it doesn't work properly, can anyone please help in fixing this problem. Thank you

Dim W
    Set W = CreateObject("Word.Application")
    set doc = W.Documents.Add
    w.Documents.Open ""
    w.Visible = True

   With w.Selection.Find
           .Text = "##brk_st_nm##"
    .Replacement.Text = "igor"
    .Replacement.Text = "Hello"
    .Forward = True    
    .Format = False
        .MatchCase = False
    .MatchWholeWord = False
        .MatchWildcards = False
    .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With


        ' Save the document.
    doc.SaveAs "c:PaymentLetter1.doc"
        ' Quit Word.
'    w.Quit
        ' Clear the variable from memory.
'    Set w = Nothing

Running VBScript File From VB6
I am wondering if it is possible to run a VBScript file (.vbs) from within a VB6 program?

I have an existing .vbs file that works fine, I just would like to have it more user friendly. I envision having a Login form, then the main form taking in data, and when you click on start, it will trigger the vbs file to run.

Any help is appreciated

Running A Vbscript From A VB Button
I am new to Visual Basic. Here's what I want to do:

I have several vbscripts that I have written. I want to use visual basic to create a form with several buttons. Each button would run one of my scripts. I can't figure out how to get a button to launch a vbscript. Any help is appreciated.

Running A Dos Command In A Vbscript
Hi! I'm trying to write a script that is to be used on older computers that do not have WMICore installed on them. On each machine that this script is run on, i need to take the name of that machine and write it to a text file. i have a few questions:

1) Will i be able to use FSO (File System Object) on computers that don't have WMI installed? I assume so, but i want to be sure FSO isn't part of the windows management instrumentation.

2) Since these machines don't have WMI, i'll have to get their computer names by using the dos "set" command. for example, the dos command
 Code:set / find "COMPUTERNAME=
will return the name of the computer. How do i run this command in a vbscript so that i can assign the result of the command to the variable and then write it to the text file. NOTE: that should be a vertical bar after "set" in the code, but i can't seem to type one in here, it keeps converting it to a forward slash.

also, i was thinking perhaps there would be an easier way to do this. can i append a line on to a text file simply using dos? if so, i could just write a batch file that would take care of this. i'm aware of the "edit" command in dos, but i would need something that can run silently in a batch file without requiring any user interaction.

thanks in advance for any help you can provide!

Edited by - Derek_Ween on 9/5/2003 12:25:03 PM

Running External VBScript (or Include In VB6)
I tried using ScriptControl and attempt to run an external VBScript made program that was made by another software, now using my VB6 creation, I am attempting to run the script the SAME way i used when I run the standalone script. HOW can I made the script that I run standalone works in the VB6 program? I'm probably not making sense and ramble on..

What other Reference or Component is good to run external script (with user input to select what they want)?



Edited by - wizpooter on 6/20/2003 5:02:55 PM

Running VBScript On Comand Line

Can anyone help me I am trying to run a VB Script from the command line . Thanks

Jeffrey Safier

Running Executable From VBScript On Solaris
Hi All,

We can run external executables from VBScript on Windows
NT by first doing a createObject ("WScript.Shell") and
then Object.Run("calc.exe")

I want to do the same thing but on Solaris 2.5+ platforms.
I installed Internet Explorer 5.0 version for Solaris
(which now acts as an ActiveX Scripting Host and now I
am able to run simple VBScript programs). I can even
make a call to CreateObject but I don't know what
type of object I should create to be able to run an
external executable (say a.out). Bottomline is : I
have not been able to make a successful call to

If I am able to find something similar to WScript.Shell
on Solaris, then my problem is solved. But it may be
the case that it is not necessary to use something like
WScript.Shell; there can be some other way to run a
executable without creating a shell; my main intention
is to run a.out from a VBScript program. If you have
any idea regarding that, please let me know.

Thanks & Regards,

Converting An Excel 2002 Macro To An Excel 95 Macro
Hi there, Iíve finally got my macro program to work (thanks everyone). Now I have to load the macro on a much older machine. I wrote the Macro on Excel 2002 and now Iím trying to run it on Excel for Windows 95 Version 7.0. Iíve loaded it up, but there are all sorts of errors. Does anyone know of a simple way to convert the macro code so it will run smoothly on Excel 7.0?

Trying To Communicate Through COM Between A Service Using VBScript And A Running ActiveX
Hi all,

I am having trouble with interprocess communication between a Service and my ActiveX EXE...

Basically, there is a Windows Service that I want to integrate with my ActiveEXE. The Service provides a VBScript interface for extensions. My ActiveX EXE is running on the desktop and has a public multiuse class which registers itself in the ROT. What I am trying to achieve is to communicate between the Service and the running ActiveX EXE without starting a new instance of the ActiveX EXE (hence the ROT entry).

Testing the ROT entry works fine using another VB app and get a reference to my ActiveX EXE class via GetObject function. So, if my ActiveX EXE Server is not running a new one is not created and if it is it gets a reference to the existing one.

So I wrote a small Vbscript plugin to do a GetObject on my ActiveX EXE from the Service.

This is where it gets ugly.

Basically the VBScript can not do a GetObject because the two processes (Service and ActiveX EXE) are running in different namespaces:
    The Service is running a LocalSystem
    The ActiveX EXE is obviously running as InteractiveUser (whoever that maybe)

So to try and bypass this security problem I have created a proxy COM object (ActiveX EXE again) which gets created by the VBScript with CreateObject. This I do with DCOM config and set it to run as the interactive user so I 'jumps' domains to the same domain as my ActiveX EXE Server.

This seems to work pretty ok but (there is always a but) the problem I am facing now is distributing this set of ActiveX EXEs (the Proxy and the Server).

I know of no easy way (and automatic) to create an install or configure the Proxy to run as Interactive.

Things I have been looking into have been the HKEY_CLASSES_ROOTAppID where the RunAs defines the setting I want to change. I also suspect using something like InstallShield could also help (I am assuming). The problem with this is that if I want to distribute a new EXE for the Proxy (an update), I will need to distribute logic to manage this as well etc etc

Basically a headache !

So, what I am asking is: (finally)

Is there an easier way of communicating between the Service and the running ActiveX EXE when security is not to be modified ?

To save you some time, I have already looked in MultiUse and GlobalSingleUse with the same problems (again need to explicitly run in the same domain).

Using DDE is not an option. (assume I am planning to move to .NET)

Using Winsock is a potential but relys on opening ports on the client that might be in use, can get messy.

I thought of Named Pipes but have no serious knowledge or way of implementing in VB.

Windows messaging (via SendMessage) just doesn't cut it.

To give another spin on the whole dilema and something some of you may have faced already:
This is simular to having a Connection Pool Manager (connection being an object) siting on a server with various clients connecting to it using different authentications (different users). I notice that in such environments the same problem occurs where the Pool Manager gets created again and again for each unique user that tries to access it. A pool manager should be only 1 instance providing access to connections from his pool. (like MTS for example)

Finally, this is meant to be a Command-Response type of communication.

If you can help, much appreciated !

(I might be asking for too much)

BTW: If this is not an appropriate forum to post my question, please feel free to move.

Edited by - f0rcegr0wn on 11/7/2003 3:16:38 PM

Running A Macro Sub
I am trying to create a sub that will run for an Excel file. For example:

Private Sub Wheelbase_Range_Click()
Set objExcel = CreateObject("Excel.Application")
Set objBook = Excel.Workbooks.Add
Set objSheet = objBook.Worksheets(1)
Enter Worksheet data here
objWorksheet.Run "Sub Macro1()" (This is where the error occurred)
End sub

Sub Macro1()
Contents of Macro 1 here
End Sub

There is more to the program, but these are the important parts. Any suggestions on how to run this Macro Sub for excel?

Thanks in advance,

Running A Macro
When I use macros I have only used them for Automating process with Excel.

My question is, how do I make it run a different program...

Example is: Opening up Internet Explorer, and playing a game written in java script (like astroids or something)

I know how to do key strokes, but I know nothing more for making run a program outside of ExCel

Running A Macro From VB6
Hello Everyone

This is time i am almost near to complete my project .. so far what i have done is extracted required information from a text file ,created an excel file and stored that information in sheet of excel ( with the help of VB6 form ) . now i have a macro and i want to run this macro on that very sheet of excel file , can i do it with help of VB6 ?
assume that i have my macro in a text file "macro.txt" at same path .. though i can include that code of macro anywhere in my vb6 code .. and i want to run it on sheet "Results" of Excel workbook "Working" .. placed at same directory .. how would i proceed . a lil code will be appreciable .. rest i ll try to understand though ..

Regards and Waiting

Running A Macro ???
I have written a macro in MS Excel. I want to run it as soon as the file is opened by the user. How do I do it?


Macro Running Once
I've got a column of dates which a want to individually change colour depending on the current date. However, I only want the macro to run once on loading of the the worksheet - is this possible, how can I stop the end of the column becoming the active cell and is my code reasonable efficient?



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Do Until ActiveCell = ""
If ActiveCell > Now() + 121 Then
Selection.Font.ColorIndex = 5 'Blue
ElseIf ActiveCell > Now() + 30 Then
Selection.Font.ColorIndex = 3 'Red
ElseIf ActiveCell < Now() Or ActiveCell <= Now() + 30 Then
Selection.Font.ColorIndex = 1 'Black
End If
ActiveCell.Offset(1, 0).Range("a1").Select

End Sub

Running A Macro In Vb
I 'm trying to open a report in vb from a command button tha triggers a macro in access. The command button says to open ru a macro that opens a report. I'm Running Win XP professiona and is in an access 03 file format. When I click the comman button in the VB project. the database is locked exclusively but does not display the report or open access. This was workin for me in a access 97 format, but now I have upgraded to a newe version of access and it is not responding. Any suggestions? Di not change any references that I know of.

Code I use:

Private Sub mnuReport_Click()
Dim objAcc As Access.Application
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("t:sergeydb2.mdb")
objAcc.DoCmd.RunMacro "JCMacro" ' ["test" is a macro which open up a report"]
objAcc.DoCmd.OpenReport ("JCFORM"), acViewPreview

End Sub

Running A Macro Through VB
I am building a VB application which needs to automate aome processes of ER studio. I am using teh automation interface of ER studio to do this.

Now i need to run a macro (.bas file) that is located in a particular directory.
Can someone suggest me a way to run this macro either by using the ER studio automation interface or any other way which uses commands outside teh scope of ER studio.
Note: I know the location of the .bas file.


Running A Macro
Hello all,

I'm having a tough time initiating a macro. My senario is as follows:

Private Sub CostAll_Click()

End Sub

Private Sub RSFCOST_Click()

End Sub

I want the first macro (Cost All) to be able to run the RSCOST macro. Essentially I have 4 unique macros on a sheet that each perform a seperate function, but there are cases where it would be easier to have 1 button click perform all the macros, so I'd like to just have that one button run all four unique macros.

I just can't seem to get the syntex to be right, I think it has something to do with the Private location of the macro(s).

Your help is greatly appreciated.

How To Check If The Excel Program Is Running Before Updating It And If It's Running, How To Close It
How to check if the excel program is running before updating it and if it's running, how to close it and do update? - thanks

Error In Running Macro From VB
Hi I am new to the forum and hoping someone can help me out. I am pretty experianced in writing VBA macros and fairly new to VB but picking it up well. I want to be able to run a program that opens a .csv and runs my macro (which I know works and have been using for a long time) which is in an add in, but I want it to run in the back ground with out the user knowing Excel has opened.

Here is the code I have:
Dim obExcelApp As Object
Dim obWorksheet As Object
Dim obfile, obmac As Object
Dim blnRunning As Boolean

'Trap errors
On Error Resume Next

'Set Excel Application reference
Set obExcelApp = GetObject(, "Excel.Application")

If Err.Number <> 0 Then
Set obExcelApp = CreateObject("Excel.Application")
blnRunning = False
blnRunning = True
End If

'open .csv
Set obfile = obExcelApp.WorkBooks.Open("c:corp.csv")

'run macro
obExcelApp.WorkBooks.Open("O:HomeSpivonkaDevelopmentToolbarMacroT oolbar.xls")
obExcelApp.Application.Run ("Interactiveaddsheets")

When it get's to the Call portion I get an error that "a workbook must contain at least one visible worksheet"

Any suggestions? My final goal is to be able to call the macro from a batch file or something similar

Running VBA Macro Without VB Installed
I am trying to run the ffg macro in excel to get the last row index:

Function getlastrow()
Dim intlastrow
intlastRow = Application.CountA(ActiveSheet.Range("A:A"))
MsgBox intlastrow
End Function

it only runs on the machines that have VB installed.
On the ones that does not VB installed, i complains about an Object/Library not found and it points that the error is at line no. 3 of the above code.

Is there any component I need to install on these machines?

Please help

Copyright © 2005-08, All rights reserved