Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use VB(A) to manipulate attachmate (6.5+)?

Control Attachmate with VB(A)

How do I use VB(A) to manipulate attachmate (6.5+)?

by  calculus  Posted    (Edited  )
While using Attachmate's built in macro language is very convenient, it is sometimes more efficient to use VB or VBA (Excel) to manipulate the system. The following code shows how to initiate the objects in VB. Once the objects are created, the coding is exactly the same as in Attachmate's Extra! Basic language. [This applies to version 6.5 or greater only]

Simply use the code snipet below to create the objects and off you go. Don't forget that these objects will need to exists in each module you want to talk to Extra.

Code:
Public Sessions As Object
Public System As Object
Public Sess0 As Object

'Extra Objects
    Set System = CreateObject("EXTRA.System")   ' Gets the system object
    If (System Is Nothing) Then MsgBox "Could not create the EXTRA System object.  Stopping macro playback.": Stop
    Set Sessions = System.Sessions
    If (Sessions Is Nothing) Then: MsgBox "Could not create the Sessions collection object.  Stopping macro playback.": Stop
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then MsgBox "Could not create the Session object.  Stopping macro playback.": Stop

...Macro Magic happens here...


Set Sessions = Nothing
Set System = Nothing
Set Sess0 = Nothing

For even more functionality, add a reference (VBA - Tools>References; VB - Project>References) to Attachmate Object Library, then use this code:

Code:
Public System As ExtraSystem
Public Sessions As ExtraSessions
Public Sess0 As ExtraSession
Public MyScn As ExtraScreen

Set System = New ExtraSystem
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession
Set MyScn = Sess0.Screen

Now you can refer to the "MyScn" object and you'll have a drop down box of all the available properties and methods.

Don't forget to unbind these objects at the end of your code:

Code:
Set Sessions = Nothing
Set System = Nothing
Set Sess0 = Nothing
Set MyScn = Nothing

Hope you find this helpful.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top