Other topics about Operation Basics
The E5071C provides 2 methods to execute a VBA program: executing a program that you previously loaded and loading and executing a program in a batch process. The execution status of the VBA program is indicated in the instrument status bar, as shown in the following figure. "Run" indicates that the program is running while "Stop" indicates that the program is stopped.
Instrument status bar indicating the status of the VBA program
The E5071C allows you to run a previous loaded VBA program using one of the four methods listed below.
Open the Macros dialog box by doing either one of the following:
On the Run menu, click Run Macro.
On the Tools menu, click Macros....
On the toolbar, click "Run Macro" icon.
Press F5 key on the keyboard.
Doing the above steps with the cursor positioned within a procedure in the code window immediately runs the program without displaying the Macros dialog box.
In the Macros dialog box, select the VBA program (procedure name) you want to run, and click the Run button.
Macros dialog box
The Macros dialog box has the following user interface elements:
Macro Name: Select the VBA program (procedure name) you want to run from the list box so its name appears here.
Macro In: Specify the project that contains the VBA program you want to run. Normally, use the default.
Run: Clicking this button runs the selected VBA program (procedure).
Cancel: Clicking this button closes the Macros dialog box and brings you back to the main screen.
Step Into: Clicking this button brings up Visual Basic Editor and put it into step-in mode, where the selected VBA program is run step by step. This mode is primarily intended for use when debugging a VBA program. For more information on step-in mode, see Debug Toolbar.
Edit: Displays the code of the selected VBA program. You can use this for re-editing your code.
Create: This button is normally dimmed.
Delete: Clicking this button deletes the selected VBA program. Take care not to inadvertently delete your VBA program before saving it.
The Macros dialog provides access to subprograms (procedures enclosed between Sub and End Sub) created in a standard module.
The E5071C allows you to run a program from E5071C screen using one of the four methods listed below.
Display the E5071C measurement screen following the instructions given in Switching to the E5071C Measurement Screen.
Run the VBA program (procedure) using the following key sequence:
Macro Setup > Select Macro - Module xxx
where "Module" is the object name (Name property shown in the property window) and "xxx" is the procedure name.
Press the Macro Run key on the E5071C front panel. For a program to be run from the measurement screen, its procedure name must be "Main" (subprogram enclosed between Sub Main() and End Sub), and its object name (Name property as displayed in the property window) must be "Module1".
When you are working with the E5071C measurement screen, the E5071C's macro environment only provides access to those VBA programs that are created as subprograms (enclosed between Sub and End Sub) in a standard module.
This section describes how to load and execute a program (VBA project) in a batch process by pressing the softkey corresponding to the program name.
Save the VBA program (VBA project file) into the following folder.
D:\VBA
This feature is available only for programs saved in D:\VBA. This feature is not available for programs saved in subfolders of D:\VBA.
When copying a VBA program to D:\VBA from another folder, copy all the files necessary to execute the program to appropriate folders. When copying a factory-installed VBA program into D:\VBA, choose only its VBA project file.
Press Macro Seup key.
Click Load & Run.
Press the softkey corresponding to the VBA project file name of the program you want to execute. The pressed VBA project is loaded and the program whose procedure name is set to "Main" (subprogram enclosed between Sub Main() and End Sub) and whose object name (Name property as displayed in the property window) is set to "Module1" is executed.
There is no limit to the number of VBA project files that can be saved in D:\VBA. However, the maximum number of programs that can be displayed as softkeys is 50.
File names of the VBA projects saved in D:\VBA are displayed as softkeys in alphabetical order.
The maximum number of characters that can be displayed in a softkey is 12. If a file name has 13 or more characters, "..." is added to the 12th character from the beginning of the program name and displayed. In this case a .vba extension is omitted.