This sample shows how to use an Excel form to enter data into a terminal screen.
If you prefer to run macros in pre-configured sessions instead of creating your own sessions, you can download the VBA Sample Sessions and open the enter-data-using-an-excel-form.xlsm (IBM) file. The download package contains everything you need to run the macros in this file. See Download the VBA Sample Sessions.
When the login button is clicked, the macro creates a session, enters the User name and Password into the program, and then navigates to the screen that has the data form. When the Enter Data button is pressed, the macro checks to make sure the user has logged in and displays a message to log in if required. If the user has logged in, the macro enters the data from the user form into the program.
This sample applies only to IBM terminals
The UserForm_Initialize() Sub creates the form displayed at the top of this article. When the Login button is clicked, the LoginButton_Click() Sub creates a new InfoConnect session as explained in Create a Session From a Microsoft Excel Macro. Then it enters the user name and password from the form into the appropriate fields on the first screen, using the ibmScreen.PutText2 method. Finally, it navigates to the screen that has the data form.
When the Enter Data button is clicked, the EnterDataButton_Click() Sub checks to make sure the user has logged in. Then it assigns the form field values to local variables and uses the PutText2 method to put the text from each form field into the appropriate program field. After the data is entered using the SendControlKey method, the user form is initialized again.