'Watch entries disappear when using CreateObject for Excel.Application
I have some VBA code in an Access database which creates an object using CreateObject("Excel.Application"). I have added a watch on a string variable. When I try to step through the code, the watch entry for the string goes blank when I hit the line where the CreateObject occurs. The little icon for the watch that looks like a pair of eye glasses is still visible, but all of the other data for the watch is invisible. If I continue stepping through the code, the watch values reappear when the Sub P2 is entered. On return to P1, the watches disappear again. Finally, when I set the object variable to Nothing the watch values reappear. This same behavior occurs if I use Word.Application or PowerPoint.Application. Also, if I click on the watch while it is invisible, the values reappear. However, if I use something like Scripting.Dictionary when creating the object, the watch remains visible. It seems to only happen with MS Office applications. I am using Office 365 with the latest updates. I also tried turning off hardware graphic acceleration, but it didn't help. This seems like a bug in the VBA environment, but I thought someone else might have had some experience with it.
Sub P1()
Dim App As Object
Dim str As String
str = "test"
Set App = CreateObject("Excel.Application")
Set App = Nothing
End Sub
Sub P2()
Debug.Print "In P2"
End Sub
Solution 1:[1]
Add a reference to the Excel object model on the COM references dialog of your VBA project. Than you may try to use Early binding instead.
See Using early binding and late binding in Automation for more information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eugene Astafiev |
