5 Application Programs
Example Program for Excel 97
150 E364xA User’s and Service Guide
To write an Excel macro:
1 You must first open a module in Excel.
2 Go to the View menu, choose Toolbars, and then select
Control Toolbox. The Control Toolbox dialog box appears.
3 Select the Command button in the dialog box.
4 Select cell A1 and drag across cell B3. The
CommandButton1 box is created.
5 To change the button name, click the right mouse button
on that button and then select Properties. The Properties
dialog box appears.
6 In the Properties dialog, change the (name) and caption
to Diode.
7 To try the example for characterizing a diode, type
Voltages in cell A4 and Current in cell B4. In cell A5,
type 0.6. Fill in cells A5 to A15 in 0.02 increments so
that cell A15 contains 0.8.
To enter the Diode macro example in this section:
1 Go to the View menu, choose Toolbars, and then select the
Visual Basic Editor icon. The Code window appears.
2 Then, type the text as shown on page 145 into the
[Module1 (code)] window. To enter the declaration for
Windows 95/NT, go to the Insert menu and choose Module.
The Module window appears.
3 Then, type the text as shown starting on page 147. This
module will configure all of the overhead required to
communicate with the power supply over the interface.
Choose the preferred interface by setting bGPIB= to Tru e
or False and change the GPIB address or RS- 232 port in
the routine OpenPort( ) contained in the module.
To run the macro, return to the Excel window, select the Run
Macro button in the dialog box, choose the macro name, and
then click Run. The power supply will reset to the power- on
condition and then step through the voltages in the
worksheet. After each step the current is measured and
recorded in the worksheet.