The code below runs when I run through it the first time but fails when I run it again. So far, the only way it works if I completely shut down my program and re-open it.
Public Sub OpenEmulator()
'Declare an object variable for the Reflection object
Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
'Declare additional Reflection objects, such as frame, terminal, and view
Dim frame As Attachmate_Reflection_Objects.frame
Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
Dim view As Attachmate_Reflection_Objects.view
'Create a new instance of Reflection
Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject
'wait until Reflection initializes
Do While app.IsInitialized = False
app.Wait (200)
Loop
'Create controls to open and display the session document.
Set frame = app.GetObject("Frame")
frame.Visible = True
Set terminal = app.CreateControl2("09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1")
terminal.HostAddress = "sourcehost"
Set view = frame.CreateView(terminal)
Set screen = terminal.screen
End Sub
I have looked up this issue and found this post regarding the same problem. However, I don't see any implicit reference problems in my code.
When I debug, the error occurs on the final line when calling terminal.screen. I'm clearly missing something but can anyone provide any help?