1.

Solve : Starting Office Apps with a switch?

Answer»

Is there any switch that I can use, when starting Excel and Access from a .BAT file, that I can interrogate from within Excel and Access using a VBA macro that will tell me that the APP was started from a .bat file and not from a user?

Thanks,using a VBA macro you can use the GetCommandLine() API routine:

Code: [Select]Declare Function GetCommandLine Alias "GetCommandLineA" Lib "KERNEL32" () As String

And then retrieve the commandline passed to Excel or Access VIA GetCommandLine(), and use string manipulation to interrogate that string to determine if your special switch was passed.Thanks.  So can I use my own non-standard switch (e.g., /1) and then interrogate the command line? Quote from: sumdumgai on December 08, 2010, 11:22:52 AM

Thanks.  So can I use my own non-standard switch (e.g., /1) and then interrogate the command line?

I can't see why not. It worked in my tests. (Excel's draconian macro handling not withstanding)Thanks for your help.  I TESTED it and it seems to work.Thanks for your help.


Discussion

No Comment Found