Running a VBA Program

Other topics about Operation Basics

Overview

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

Running a Previously Loaded VBA Program

Running a Program from Visual Basic Editor

The E5071C allows you to run a previous loaded VBA program using one of the four methods listed below.

  1.  Open the Macros dialog box by doing either one of the following:

  1. 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:

  1. Macro Name: Select the VBA program (procedure name) you want to run from the list box so its name appears here.

  2. Macro In: Specify the project that contains the VBA program you want to run. Normally, use the default.

  3. Run: Clicking this button runs the selected VBA program (procedure).

  4. Cancel: Clicking this button closes the Macros dialog box and brings you back to the main screen.

  5. 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.

  6. Edit: Displays the code of the selected VBA program. You can use this for re-editing your code.

  7. Create: This button is normally dimmed.

  8. 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.

Running a Program from the E5071C Measurement Screen

The E5071C allows you to run a program from E5071C screen using one of the four methods listed below.

  1. Display the E5071C measurement screen following the instructions given in Switching to the E5071C Measurement Screen.

  2. Run the VBA program (procedure) using the following key sequence:

Loading and Executing Programs in Batch Process

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.

  1. Save the VBA program (VBA project file) into the following folder.
    D:\VBA

  2. Press Macro Seup key.

  3. Click Load & Run.

  4. 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.