Croc:
Thanks for looking into this. It takes about a minute or so before the message appears.
My apologies, but I did leave out one important fact. Once Visio creates the Excel instance, the next step is for the Excel instance to asynchronously connect to Visio and execute a Visio Sub (via right-click menu choice). It’s that Visio Sub that takes a long time to run, and Excel is waiting for Visio to finish what Excel initiated.
Here is the tested Excel VBA code for invoking a Visio Sub from the Excel instance that was created by the Visio Sub:
Sub TalkToVisio ()
Dim VisioApp As Object
Dim VisioAppDoc As Object
Set VisioApp = GetObject(, "Visio.Application") 'returns Visio app if it is running, error if not
If Err <> 0 Then
MsgBox " Visio is not available. ", vbInformation
Else
Set VisioAppDoc = VisioApp.ActiveDocument
VisioAppDoc.ExecuteLine "ThisDocument.LongRunningVisioSub"
End If
Set VisioApp = Nothing
End Sub
As an aside, I’d be happy to hear of a better way of connecting Visio and Excel and having Excel execute the Visio Sub. This approach has the problem that only one instance of Visio can be running, or else the Excel macro could possibly latch onto the wrong instance of Visio. But this approach works, and the user instructions tell them to first close all other instances of Visio. And if it does grab the wrong instance, Excel crashes with an “I told you so!” message.
Here's an extra credit question: Do the same connection, except have Excel create the Visio instance, and Visio runs an Excel Sub. But that has the same flaw: how does Visio know which instance of Excel created it?
Someday I will stop living on the extreme edges of Visio functionality. But not today. Besides, it's way too much fun!
Thanks again,
- Ken