Jon von der Heyden
MrExcel MVP, Moderator
- Joined
- Apr 6, 2004
- Messages
- 10,912
- Office Version
- 365
- Platform
- Windows
Hi
I have asked similar question to this before but it involved programming the VBE (VB extensibility) and a method I am attempting to avoid.
I have a workbook that I would like to make sure it opens in it's own instance of the application, and that any subsequent files opened are not opened in this instance.
I am using a separate workbook (loader) to call the workbook that I want open in its' own dedicated instance.
This code is in the loader:
The idea is that the loader can be called from the windows start menu or from desktop. It should point to the workbook, open it in it's own instance, and the the loader should close. If the loader was opened in a new instance then that instance should close. If the loader was opened in an existing instance with other workbooks already open then only the loader workbook should be closed and the instance remain.
Problem:
This doesn't appear to be loading the workbook in it's own instance.
The IgnoreRemoteRequests is not resetting to False, hence trying to open any other workbook when the entire app is closed doesn't work if I attempt to open it from windows explorer (instead of Excel). I get error msg 'There was a problem sending te command to the program'.
Any ideas on how to achieve much appreciated. Thanks
I have asked similar question to this before but it involved programming the VBE (VB extensibility) and a method I am attempting to avoid.
I have a workbook that I would like to make sure it opens in it's own instance of the application, and that any subsequent files opened are not opened in this instance.
I am using a separate workbook (loader) to call the workbook that I want open in its' own dedicated instance.
This code is in the loader:
Code:
Private Sub Workbook_Open()
Dim app As Excel.Application
Dim strUIPath As String
Dim wkbUIApp As Workbook
Dim blnErr As Boolean
Set app = New Excel.Application
strUIPath = Environ$("ProgramFiles") & "\Recruitment Cost Tracker\RCT_App.xls"
With app
.IgnoreRemoteRequests = True [COLOR=DarkRed]'So that subsequent files do not interfere with this instance[/COLOR]
.Visible = False
.DisplayAlerts = False
End With
On Error Resume Next
Set wkbUIApp = app.Workbooks.Open(Filename:=strUIPath)
If wkbUIApp Is Nothing Then
blnErr = True
End If
On Error GoTo 0
If blnErr Then
MsgBox Prompt:="The application failed to load!", _
Buttons:=vbCritical + vbOKOnly, _
Title:="Recruitment Cost Tracker"
End If
If Application.Workbooks.Count > 1 Then
ThisWorkbook.Close SaveChanges:=False
Else
With Application
.IgnoreRemoteRequests = False
.Quit
End With
End If
End Sub
The idea is that the loader can be called from the windows start menu or from desktop. It should point to the workbook, open it in it's own instance, and the the loader should close. If the loader was opened in a new instance then that instance should close. If the loader was opened in an existing instance with other workbooks already open then only the loader workbook should be closed and the instance remain.
Problem:
This doesn't appear to be loading the workbook in it's own instance.
The IgnoreRemoteRequests is not resetting to False, hence trying to open any other workbook when the entire app is closed doesn't work if I attempt to open it from windows explorer (instead of Excel). I get error msg 'There was a problem sending te command to the program'.
Any ideas on how to achieve much appreciated. Thanks