macros from command line

C

Cyberwolf

Is there a switch that will run a macro in my personal workbook from a
command line?
 
G

Guest

Cyberwolf said:
Is there a switch that will run a macro in my personal workbook from a
command line?

------------------------

I don't quite understand what you mean by command line within the Excel context?

What you can do if you wish, is to create a button for it. Push the button and
the macro executes. You can place the button either on a sheet, or up in your
tool bar.

Bill
 
G

Guest

Cyberwolf said:
Is there a switch that will run a macro in my personal workbook from a
command line?

------------------------

I don't quite understand what you mean by command line within the Excel context?
You know you can assign a key chord to invoke a macro? Ctrl-a, Ctrl-b, etc.

What you can do if you wish, is to create a button for it. Push the button and
the macro executes. You can place the button either on a sheet, or up in your
tool bar.

Bill
 
J

Jef Gorbach

Bill Martin -- (Remove NOSPAM from address) said:
------------------------

I don't quite understand what you mean by command line within the Excel context?
You know you can assign a key chord to invoke a macro? Ctrl-a, Ctrl-b, etc.

What you can do if you wish, is to create a button for it. Push the button and
the macro executes. You can place the button either on a sheet, or up in your
tool bar.

Bill

The *simple* answer is no because Excel lacks Word's /m command line switch
.... however Michael Bednarek of the microsoft.public.excel.programming forum
helped develope the following WSH/VBS work-around.
Save excel.vbs somewhere along your command Path
(ie:c:\windows\command\e.vbs) then either setup shortcut icons to indivual
macros or invoke it directly via the Windows Run box.
ie: [Windows]+R excel.vbs macroname [enter]

' Filename: excel.vbs
' Overcomes Excel inability to run macros from the command line
' Usage: excel.vbs modulename.macroname
' modulename not required if macroname in default Module1
' requires WSH to be installed
'
'open excel
Dim macro
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
xlapp.visible = true
xlapp.workbooks.add
xlapp.workbooks.open "C:\Program Files\Microsoft
Office\Office\Xlstart\personal.xls"
'
'now run macro
If wscript.arguments.count = 0 Then
'do nothing
Else
macro = "Personal.xls!" & WScript.Arguments.item(0)
xlapp.run macro
End If
 
Top