Question

I need to open multiple excel files(which contains a macro that runs as soon as it opens) through a bat file. It works when I type the line in the command prompt however, when I make the .BAT, it doesn't work correctly. the format I’m using is really just

START "Path\Excelfile.xlsm"

START "Path\Excelfile.xlsm"

START "Path\Excelfile.xlsm"

I'm fairly new to this so if any help would be greatly appreciated. Thanks for your time.

Was it helpful?

Solution

generally:

START /D"path_to_program" program.exe "file_to_open_or_another_parameters"

in your case:

START /D"path_to_excel" excel.exe "Excelfile.xlsm"

my foolproof example (attested with PSPad, as I haven't excel installed):

start /D"C:\Program Files\PSPad editor" PSPad.exe "c:\temp\debug.txt"

OTHER TIPS

START needs a first parameter of a title name. Try:

START "" "Path\Excelfile.xlsm"

Edit: It doesn't need a first parameter of a title name, but if you give it a first parameter in quotes, it reads that as if you are trying to set a title name instead of a program to run, so you have to work around that.

See the help with start /? - the first optional parameter is a quoted window title.

C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [command/program] [parameters]

    "title"     Title to display in window title bar.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top