Application level events and processes in Excel are restricted to a single instance of the application.
In the past I have prevented users from opening more than one instance of Excel when my add-in is running using the following code.
Private Sub KillDuplicateProcesses()
Dim objWMIService As Object
Dim colItems As Variant
Dim objItem As Object
Dim intCount As Integer
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.InstancesOf("Win32_Process")
For Each objItem In colItems
intCount = intCount + Abs(LCase(objItem.Name) = "excel.exe")
Next
If intCount > 1 Then
MsgBox "Excel is already running.", vbCritical
Application.Quit
End If
Set objWMIService = Nothing
Set colItems = Nothing
End Sub
I am wondering, however, if there is a way to safely run an add-in while multiple instances of Excel are running.
For example, if I do something like this in VBA:
Application.MoveAfterReturnDirection = xlDown
This change and any changes to CommandBar objects should be reflected across all instances of Excel, each with its own window, simultaneously.
Thanks!