Connecting Excel to Reflection 2011

cly28

New Member
Joined
Jul 9, 2013
Messages
1
I am trying to write macros in VBA to connect Excel to a current session of Reflection 2011. I used to use an older version of Reflection and this was rather easy. However, I have been upgraded to Reflection 2011 and this is more difficult. The code I have from using the help guides is:

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")


Set Terminal = App.CreateControl("C:\MAIN.rd3x")
Set screen = Terminal.screen
Set Frame = App.GetObject("Frame")
Frame.Visible = True
Set View = Frame.CreateView(Terminal)

The problem is this code opens a new frame (Tab) within Reflection rather that using the current one. I am not sure if I have to change the Set View, Set Frame, etc... I have tried to use Set View = Frame.GetViewsByName but I am getting a compile error: Object required.

Can anyone help with the code that should go in the beginning of the Excel macro so that it connects to the current session of Reflection 2011. Thank you
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Cly28,

Thanks for your code, the only one I found so far working to connect to Reflection. I was formerly on MyExtra and the process was somehow different, I needed to re-write some parts of my code with the new instructions.
Anyway, I managed to either get the running app (resp. session) and if not found, run one. Here is my code - only an adaptation from yours [sorry, written in french !]:

Code:
    Dim App As Attachmate_Reflection_Objects_Framework.ApplicationObject
[FONT=Verdana]   Dim Terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal[/FONT]
[FONT=Verdana]    Dim Frame As Attachmate_Reflection_Objects.Frame[/FONT]
[FONT=Verdana]    Dim View As Attachmate_Reflection_Objects.View[/FONT]
[FONT=Verdana]    Dim MyScreen As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmScreen[/FONT]
[FONT=Verdana]
[/FONT]
[FONT=Verdana]' Cherche une instance de l'application[/FONT]
[FONT=Verdana]    On Error Resume Next[/FONT]
[FONT=Verdana]    Set App = GetObject(, "Attachmate_Reflection_Objects_Framework.ApplicationObject")[/FONT]
[FONT=Verdana]    On Error GoTo 0[/FONT]
[FONT=Verdana]    'si aucune trouvée, on la lance[/FONT]
[FONT=Verdana]    If (App Is Nothing) Then[/FONT]
[FONT=Verdana]        Set App = CreateObject("Attachmate_Reflection_Objects_Framework.ApplicationObject")[/FONT]
[FONT=Verdana]        'boucle pour laisser l'appli charger[/FONT]
[FONT=Verdana]        Do[/FONT]
[FONT=Verdana]            DoEvents[/FONT]
[FONT=Verdana]        Loop Until App.IsInitialized[/FONT]
[FONT=Verdana]        'si on n'a toujours rien, pb ailleurs, alerter l'utilisateur et quitter[/FONT]
[FONT=Verdana]        If (App Is Nothing) Then[/FONT]
[FONT=Verdana]            MsgBox "Impossible de créer l'objet du système Reflection. L'exécution de la macro est interrompue."[/FONT]
[FONT=Verdana]            Exit Sub[/FONT]
[FONT=Verdana]        'sinon, on charge la session Macros[/FONT]
[FONT=Verdana]        Else[/FONT]
[FONT=Verdana]            On Error Resume Next[/FONT]
[FONT=Verdana]            Set Terminal = App.CreateControl("[...]\MyDocs\Attachmate\Reflection\Macros.edp")[/FONT]
[FONT=Verdana]            On Error GoTo 0[/FONT]
[FONT=Verdana]            If (Terminal Is Nothing) Then[/FONT]
[FONT=Verdana]                MsgBox "Impossible de créer la Session 'Macros'. L'exécution de la macro est interrompue."
                Exit Sub
            End If
        End If
    'si une instance est trouvée, on cherche une éventuelle session Macro déjà chargée
    Else
        On Error Resume Next
        a = App.GetControlsByFilePath("[...]\MyDocs\Attachmate\Reflection\Macros.edp")
        For Each Sess In a
            If Sess.SessionFilePath = "[...]\MyDocs\Attachmate\Reflection\Macros.edp" Then Set Terminal = Sess
        Next Sess
        On Error GoTo 0
        'si session Macro pas trouvée alors on la charge
        If (Terminal Is Nothing) Then
            On Error Resume Next
            Set Terminal = App.CreateControl("\\f-seth\home1$\as00668\MyDocs\Attachmate\Reflection\Macros.edp")
            On Error GoTo 0
            If (Terminal Is Nothing) Then
                MsgBox "Impossible de créer la Session 'Macros'. L'exécution de la macro est interrompue."
                Exit Sub
            End If
        End If
    End If

    'Cela fait, on charge les éléments de travail et on s'assure que la fenêtre est visible
    Set Frame = App.GetObject("Frame")
    Frame.Visible = True
    'la vue, qui va connecter la session, n'est à charger que si la session n'était pas précédemment ouverte
    On Error Resume Next
    Set View = Frame.CreateView(Terminal)
    On Error GoTo 0
    Set MyScreen = Terminal.Screen
    'sert juste de tempo pour être sûr que l'écran est bien chargé - un home ne fait jamais de mal :)
    MyScreen.SendControlKeySync (ControlKeyCode_Home)
'--------------------------------------------------------------------------------


    With MyScreen
[...]



[/FONT]

Hope this helps.

Cheers
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,989
Members
452,541
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top