Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,074
- Office Version
- 2019
- Platform
- Windows
The first code closes any new workbook and the second code opens a new instance. If an attempt to open an existing file or start a new workbook, Instead of closing the new workbook, I would like it to open in a new instance. How can I combine them?
VBA Code:
If Workbooks.Count > 1 Then
For Each wbk In Application.Workbooks
If (Not wbk Is Application.ThisWorkbook) Then
MsgBox "Opening additional workbook in the same instance is restricted while using Traderking - Trade Journal.", vbCritical, "Traderking - Trade Journal"
wbk.Close SaveChanges:=False
End If
Next
End If
VBA Code:
Sub New_Instance_of_Excel()
Dim objXL
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Add
End Sub