Excel 宏 VBA 连接到 Reflection Desktop 以打开新会话

问题描述 投票:0回答:2

我正在尝试在 Reflection 中实现流程自动化,并使用 Attachmate 站点中的代码来打开连接:

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 or BeginInvoke cannot be called on a control until the window handle has been created

知道为什么会发生这种情况吗?我尝试了一切,但似乎没有任何效果。 尝试创建新连接时我也遇到同样的错误

excel vba reflection
2个回答
0
投票

感谢您的评论。我找到了解决方案。在运行之前,您需要通过转到“工具”>“参考”来激活 VBA 中的 Attachmate 和 Reflection 库。


0
投票

所以我有一个类似的宏,它可以在反射桌面中自动化 css。应用程序标头是 Reflection Workspace - CSS.rd3x 我已签入上述引用,但当我尝试运行它时,它给出错误“加载 dll 时出错” 我已经删除并重新安装了整个应用程序,但仍然存在同样的问题。知道出了什么问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.