View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Drinkmilk Drinkmilk is offline
external usenet poster
 
Posts: 2
Default Execute a macro from command line: possible or not ?

Thanks for your answers guys.

Papou, your example allow me to run the macro that is "auto-run" in the
sample1.xls file, does'nt it ?

Actually, I have written a macro in a .xla file, it contains a function that
open a file with the "Open and repair" option when it is called. I have put
this macro in the XLStart folder so that it is loaded each time Excel is
opened. In some specific context, I would like to call my function, so not
systematically. As I said in my first post, this is very easy with Word, but
I still did not found the way to do it with Excel.

Sorry if was not clear with py first post, I hope it is better now.


"papou" wrote:

Hello Drinkmilk
This is possible using a script.
Paste this into a new text file and amend accordingly.
Save with .VBS suffix and double-click to run.

Dim objxl, xlwbk
Set objxl = CreateObject("Excel.Application")
objxl.Visible = True
Set xlwbk = objxl.Workbooks.Open("C:\Documents and Settings\papou\My
documents\Sample1.xls")
objxl.Run ("Go")

HTH
Cordially
Pascal


"Drinkmilk" a écrit dans le message de
news: ...
Hello,

I would like to know wether it is possible to run a macro in command line
mode for Excel. After having searched in the Web and on this forum, I have
seen several comments saying that it is impossible. I am very surprised
because this is possible with Word, using for example:
"C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
/mFileOpenAndRepair

Can you confirm if really this is not possible with Excel ?

Many thanks