0

我公司最近从 Attachmate EXTRA 升级!附加反射。我们有许多在屏幕抓取时额外运行的宏。基本上,你会按下一个按钮来启动宏,它会要求你选择你想在哪个额外的屏幕上运行它(我们总是为不同的系统打开 3+),然后宏将只使用最近选择的(主动)会话。这是代码:

Private Function GetReflectionWindow(sessionName As String) As ExtraScreen
'Gets the most recent active reflection or extra window.
'Requires Reference: EXTRACOM

    Dim sys As ExtraSystem: Set sys = CreateObject("EXTRA.System")
    Dim sess As ExtraSession

    'Set current sesion to most recently active session
    If MsgBox("Click on the " & sessionName & " session and click 'OK' to continue.", vbOKCancel) = vbCancel Then End

    Set sess = sys.ActiveSession

    'Checks the session
    If sess Is Nothing Then
        MsgBox "Could not locate a Reflection or Extra session!", vbCritical
        End
    Else
        Set GetReflectionWindow = sess.Screen
        sess.Activate
    End If

End Function

这不再适用于反射系统。相反,我在这里查看了此文档。问题是当您使用 CreateObject 或 GetObject 时,它只查看第一个打开的实例,而不是活动的实例。

Sub GetNewReflectionWindow()

    Dim App As Attachmate_Reflection_Objects_Framework.ApplicationObject
    Dim screen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen
    Dim Terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
    Dim Frame As Attachmate_Reflection_Objects.Frame
    Dim View As Attachmate_Reflection_Objects.View


    Set App = GetObject(, "Attachmate_Reflection_Objects_Framework.ApplicationObject")

End Sub

我在文档或对象浏览器中看不到任何可以让我像 Extra.System 那样选择活动会话的内容。

4

1 回答 1

0

我有同样的问题,终于在所有地方的 MicroFocus 文档中找到了解决方案!在 VBA 宏代码中访问所有打开的“反射工作区”对象

基本上,继续使用 CreateObject 来获取工作区,但是在一个循环中进行,在你去的时候重命名每个:

    Dim oSession As Object
    'find all open sessions
    Do
        Set oSession = CreateObject("Reflection Workspace")
        oActiveSession.AutomationServerName = "Unused"
    Loop

    'rename sessions back to original
    Do
        Set oActiveSession = CreateObject("Unused")
        oActiveSession.AutomationServerName = "Reflection Workspace"
    Loop

我将它放入它自己的函数中,因为当您用完工作区时 CreateObject 会引发错误。

于 2020-02-03T18:29:10.893 回答