Quick Start > Record and Edit a Macro |
You can record macros to automate the following types of actions:
You cannot record:
Recording a macro is an easy way to get started on a more complex macro. After you save a recorded macro, you can edit it in the Visual Basic editor to add functionality and make it easier to maintain.
If you are working with an unstructured display format (such as Open Systems terminals), you'll probably find it useful to record a macro and then look at the recorded code to get information such as the strings returned by a host or the screen positions of selected data.
This example shows how to record a macro that copies data to the clipboard. It also shows how to modify the recorded code to disconnect the session after the data is copied.
![]() |
This article contains tabbed content that is specific to each terminal type. Be sure the tab for your terminal type is selected. |
Recorded macro code to declare variables |
Copy Code
|
---|---|
Sub CopyData() '--------------------------------------------------------------------- ' Generated by Attachmate InfoConnect 2014 (15.6.660.0) ' Generated by the Macro Recorder on 7/7/2014 5:13:44 PM '--------------------------------------------------------------------- 'Common variable declarations Dim ibmCurrentTerminal As IbmTerminal Dim ibmCurrentScreen As IbmScreen Dim hiddenTextEntry As String Dim returnValue As Integer Dim timeout As Integer timeout = 15000 Set ibmCurrentTerminal = ThisFrame.SelectedView.control Set ibmCurrentScreen = ibmCurrentTerminal.screen ibmCurrentScreen.SetSelectionStartPos 1, 24 ibmCurrentScreen.ExtendSelection 14, 44 ibmCurrentScreen.Copy End Sub |
Disconnect the session |
Copy Code
|
---|---|
...
ibmCurrentTerminal.Disconnect
End Sub
|
Recorded Macro Code |
Copy Code
|
---|---|
Sub CopyData() Call ExternalRecorded1 End Sub Sub ExternalRecorded1() ' Generated by the InfoConnect Macro Recorder on 07-08-2014 12:00:37.96. ' Generated by Attachmate InfoConnect 2014 (15.6.660.0). Dim osCurrentScreen As Screen Dim osCurrentTerminal As Terminal Dim returnValue As Integer Set osCurrentTerminal = ThisFrame.SelectedView.control Set osCurrentScreen = osCurrentTerminal.Screen 'Select and copy text from the screen osCurrentScreen.SelectText 2, 22, 19, 55, RegionOption_Wrapped 'Press EditCopy (Copy the selection and put it on the Clipboard). osCurrentScreen.Copy Exit Sub 'Recording stopped at 12:00:51.92. End Sub |
Disconnect the session |
Copy Code
|
---|---|
...
osCurrentTerminal.Disconnect
End Sub
|
To run the macro from the editor, place the cursor in the code window and press F5.
When you record a macro, the macro recorder creates variables for two important objects (the names of the objects are unique to the terminal type):
The macro uses the ThisFrame property to get the control for the session that is selected (displayed in the workspace) during the recording. ThisFrame is a property that is available in any InfoConnect macro. It returns the top-level user interface component for the workspace and can be used to access the controls (sessions) running in the workspace.
For more about these objects, see Using the InfoConnect Object Model.