Excel宏VBA连接到反射桌面以打开新会话
我正在尝试在反射中自动化一个过程,并使用attachmate站点的代码打开连接:Excel宏VBA连接到反射桌面以打开新会话,excel,vba,reflection,Excel,Vba,Reflection,我正在尝试在反射中自动化一个过程,并使用attachmate站点的代码打开连接: Private Sub OpenReflectionIBMSession() 'Declare an object variable for the Reflection application Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject 'Declare frame, terminal,
Private Sub OpenReflectionIBMSession()
'Declare an object variable for the Reflection application
Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
'Declare frame, terminal, and view object variables:
Dim frame As Attachmate_Reflection_Objects.frame
Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
Dim view As Attachmate_Reflection_Objects.view
'If an instance of Reflection is open, get a handle to it
On Error Resume Next
Set app = GetObject("Reflection Workspace")
'Otherwise, create a new instance of Reflection
On Error GoTo 0
If IsEmpty(app) Or (app Is Nothing) Then
Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject
End If
With app
'wait until Reflection initalizes
Do While .IsInitialized = False
.Wait 200
Loop
'Get a handle to the Frame object
Set frame = .GetObject("Frame")
'Make the frame visible so we can view the workspace
frame.Visible = True
End With
'Create an Ibm3270 control using an .rd3x session document file
Set terminal = app.CreateControl(Environ$("USERPROFILE") & _
"\Documents\Micro Focus\Reflection\" & "mySavedSession.rd3x")
'Create a view so that we can display the session
Set view = frame.CreateView(terminal)
End Sub
当执行到达终点时
Set terminal = app.CreateControl(Environ$("USERPROFILE") & _
"\Documents\Micro Focus\Reflection\" & "mySavedSession.rd3x")
我得到一个运行时错误,说
在创建窗口句柄之前,无法对控件调用Invoke或BeginInvoke
知道为什么会这样吗?我什么都试过了,但似乎都不管用。
我在尝试创建新连接时也会遇到同样的错误谢谢您的评论。我找到了解决办法。在运行VBA之前,您需要在工具>参考中激活附件和反射库。谢谢您的评论。我找到了解决办法。在运行VBA之前,您需要通过转到“工具”>“引用”激活VBA中的附件和反射库。
Invoke
和BeginInvoke
是.NET方法。错误来自反射应用程序对象。您需要检查API,看看在CreateControl
步骤之前是否缺少一个步骤。我找到了这篇文章,看起来您正确地遵循了文档。您最好联系他们的支持,因为错误在他们的代码中Invoke
和BeginInvoke
是.NET方法。错误来自反射应用程序对象。您需要检查API,看看在CreateControl
步骤之前是否缺少一个步骤。我找到了这篇文章,看起来您正确地遵循了文档。您最好联系他们的支持,因为错误在他们的代码中。