Sam Hamels
New Member
- Joined
- Mar 20, 2018
- Messages
- 49
Hi All,
I use the following code (found here) to do the following:
- Save
- Set up a Windows prompt that will re-open the Excel file in a few seconds
- Close the workbook
- Prompt triggers a re-opening of the workbook
I need to run several separate instances of Excel at the same time, and they each need to use this code.
The separate Excel instances are originally set-up by left-mouse clicking the open Excel program in the bottom toolbar and clicking Excel while continuously holding ALT (you then get a prompt asking if you want to open a new separate Excel instance). This allows me to run macro's in each separate Excel instance simultaneously.
The problem is that, when each of the separate Excel instances executes the code above, they will all be re-opened in a single Excel instance.
My question therefore is: how could I adapt the code above, to make the Windows prompt re-open the Excel file as a new, separate Excel instance.
After being re-opened, each Excel instance (workbook) automatically starts executing a macro, which doesn't work out when they re-open all together as one (non-separated) Excel instance, because the whole instance then becomes 'busy' doing one single macro that started running in whichever instance/workbook that re-opened first.
Cheers,
Sam
I use the following code (found here) to do the following:
- Save
- Set up a Windows prompt that will re-open the Excel file in a few seconds
- Close the workbook
- Prompt triggers a re-opening of the workbook
Code:
Sub SaveCloseReOpen()
Dim strCMD As String
strCMD = "CMD /C PING 10.0.0.0 -n 1 -w 5000 >NUL & Excel.exe " & Chr(34) & ThisWorkbook.FullName & Chr(34)
ThisWorkbook.Save
Shell strCMD, vbNormalFocus
If Application.Workbooks.Count = 1 Then
Application.Quit
Else
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
I need to run several separate instances of Excel at the same time, and they each need to use this code.
The separate Excel instances are originally set-up by left-mouse clicking the open Excel program in the bottom toolbar and clicking Excel while continuously holding ALT (you then get a prompt asking if you want to open a new separate Excel instance). This allows me to run macro's in each separate Excel instance simultaneously.
The problem is that, when each of the separate Excel instances executes the code above, they will all be re-opened in a single Excel instance.
My question therefore is: how could I adapt the code above, to make the Windows prompt re-open the Excel file as a new, separate Excel instance.
After being re-opened, each Excel instance (workbook) automatically starts executing a macro, which doesn't work out when they re-open all together as one (non-separated) Excel instance, because the whole instance then becomes 'busy' doing one single macro that started running in whichever instance/workbook that re-opened first.
Cheers,
Sam
Last edited: