ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macros from command line (https://www.excelbanter.com/excel-discussion-misc-queries/35863-macros-command-line.html)

Cyberwolf

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

Bill Martin -- (Remove NOSPAM from address)

Cyberwolf wrote:
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

Bill Martin -- (Remove NOSPAM from address)

Cyberwolf wrote:
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

Jef Gorbach


"Bill Martin -- (Remove NOSPAM from address)"
wrote in message ...
Cyberwolf wrote:
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


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





All times are GMT +1. The time now is 09:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com