Search code examples
excelvbaattachmate-extra

Attachmate Reflection VBA automation error


Using Attachmate Reflections Standard Suite 2011 R2 using excel for a source dataset. The terminal I am attempting to automate required the F9 key to submit information but when I attempt to send that key I get a "the given key was not present in the dictionary" error. All other keys I attempt to send to the terminal application appear to work fine. Below is a code snippet:

sub TerminalTest()
Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
Dim frame As Attachmate_Reflection_Objects.frame  

Set app = GetObject("Reflection Workspace")
Set frame = app.GetObject("Frame")
Set MGlobals.gScreen = frame.SelectedView.Control.Screen
With MGlobals.gScreen
    .SendKeys "A"
    .SendKeys "123"
    .SendKeys "456"
    .SendControlKey ControlKeyCode_Return
    .SendKeys "780ABC"
    .SendControlKey ControlKeyCode_Return
    .SendKeys "ZYX"
    .SendControlKey ControlKeyCode_Return
    .SendKeys "TEST"
    .SendControlKey ControlKeyCode_Return
    .SendControlKey ControlKeyCode_F9
End with
End sub

I'm at a bit of a loss because the reflection API documentation shows to use ControlKeyCode_F9 for the function keys but it the code is throwing an error.

Any help is appercaited.


Solution

  • So it seems there is very little information on Attachemate Reflections even via Google. This is confirmed by the lack of feedback here as well but I wanted to update this in case any others in the future experience a similar frustrating experience.

    Attachmate Reflections 2011 installs 4 reference files:

    Attachmate_Reflection_Objects
    Attachmate_Reflection_Objects_Framework
    Attachmate_Reflection_Objects_Emulation_OpenSystems
    Attachmate_Reflection_Objects_Emulation_IbmHosts
    

    Documentation on their website instructs would be programmers to enable all 4 references within VBA to allow for automation. Herein lies the problem - there appears to be a conflict with Attachmate_Reflection_Objects_Emulation_OpenSystems and Attachmate_Reflection_Objects_Emulation_IbmHosts. When both are enabled, function keys and other Attachmate built in functions simply will not work. I stumbled on the error after much head banging against my keyboard by browsing the Object Browser and noticing a clear difference.

    Anyways, I realize there are few who probably still use Attachmate but for those poor bums who are roped into this application by their corporation, maybe this will help

    Thanks,