View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Michael Bednarek[_8_] Michael Bednarek[_8_] is offline
external usenet poster
 
Posts: 21
Default Run Excel Macro from Command Line

On Sun, 12 Jun 2005 21:25:08 -0700, "Al Franz"
wrote in
microsoft.public.excel.programming:

Is there a way to run an Excel macro from a command line. Such as when you
open up a file to have it run the macro. Since I want to do this for files
that are newly created I can not program the file to run the macro at
startup. Is there a command line option in excel?


Not to my knowledge. You have to write some VBS code for that. E.g.:

Option Explicit
Dim objXL

Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open "d:\dir\fubar.xls"
objXL.Visible = TRUE ' Optional
objXL.Run("yourMacro")
objXL.Quit
Set objXL = Nothing

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"