4

I run multiple Excel instances / files which require a manual PC restart daily. Currently I save all my Excels, restart the PC, then have to open each file separately, which is quite manual. Is anyone aware of a program I can run that will open the same Excel files in separate Excel instances after reboot?

Solution:

@echo off
setlocal EnableDelayedExpansion
set "excel=C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"
for %%a in (
 "R:\Other Stuff\Name\text_excel_1.xlsx"
 "R:\Other Stuff\Name\text_excel_2.xlsx"
) do start "" "%excel%" "%%~a"

Previous Edits:

I've gotten this far with a batch BUT the second Excel instance won't open unless I close the first.

"C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"
"C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"
"C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"

Has anyone see this before?

EDIT: have tried using the start command, but this opens the both files in the same instance. How would I go about opening them in multiple instances?

start /d "R:\Other Stuff\Name" test_excel_1.xlsx
start /d "R:\Other Stuff\Name" test_excel_1.xlsx

EDIT 2:

R is a share drive; this opens multiple Excel instances but can't find the files. Do I need to modify for network drives? But I was able to open them using the start /d command which is a tad puzzling for me.

@echo off
setlocal EnableDelayedExpansion
set "excel=C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe"
for %%a in (
 "R:\Other Stuff\Name\text_excel_1.xlsx"
 "R:\Other Stuff\Name\text_excel_2.xlsx"
) do start "" "%excel%" "%%~a"

Error is now:

'R:\Other Stuff\Name\test_excel_2.xlsx' cannot be found. Checking spelling or try a different path.

Does anyone see anything wrong with this? start /d finds the file but the code starting with @echo off does not find the file.

Community
  • 1
  • 1
JSNoob
  • 71
  • 1
  • 2
  • 9
  • How are you launching the batch file? Double-click from Explorer? From command line? From scheduled job? – aphoria Apr 25 '17 at 14:12

1 Answers1

4

to open all xlsx files in current folder with excel:

for %%a in (*.xlsx) do start "" "%%a"

(for use on command line, replace every %%a with %a)

To open every file in a separate EXCEL instance:

@echo off
setlocal EnableDelayedExpansion
set "excel=C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE"
for %%a in (
 "R:\Other Stuff\Name\Document1.xls"
 "C:\users\JSNoob\documents\my Passwords.xlsx"
) do start "" "%excel%" "%%~a"

(adapt the excel path to fit your system and add the files, you need)

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • not quite what I'm after. I've done some research and have found I should start command start /d "R:\Other Stuff\Name" test_excel_1.xlsx start /d "R:\Other Stuff\Name" test_excel_1.xlsx – JSNoob Apr 25 '17 at 13:12
  • how about now ? – Stephan Apr 25 '17 at 13:24
  • How would I adopt this if I knew the path of each file? The folder contains multiple files I do not need – JSNoob Apr 25 '17 at 13:25
  • VERY close! I've now open multiple excel instances but now I can't find the files... Does it work differently if the path is a network drive? – JSNoob Apr 25 '17 at 13:41
  • nope - I tested it with a network drive: working fine here. – Stephan Apr 25 '17 at 13:43
  • Very weird, thank you for your help... Can't shake this error though – JSNoob Apr 25 '17 at 13:56