Chapter 6 Application Programs
Example Program for Excel 97
140
To write an Excel macro you must first open a module in Excel. Go to the View
menu, choose Toolbars, and then select Control Toolbox. The Control Toolbox
dialog box appears. Select the Command button in the dialog box. Click cell
A1 and drag across the cell B3. The “CommandButton1” box is created. To
change the button name, click the right mouse button on that button and then
select Properties. The Properties dialog box appears. In the Properties dialog,
change the “(name)” and “caption” to “Diode”. 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 the cells A5 to A15 in 0.02 increments so that cell A15
contains 0.8.
To enter the “Diode” macro example in this section, go to the View menu,
choose Toolbars, and then Visual Basic Editor icon. The “Code window”
appears. Then type the text as shown on page 139 into the “[Moudle1 (code)]”
window. To enter the declaration for Windows
Ò
95/NT, go to the Insert menu,
choose Module. The “Module window” appears. Then type the text as shown
starting on page 141. 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 “True” or “False” and change the
GPIB address or RS-232 port in the routine “OpenPort( )’’ contained in the
module.
To run the macro, return back to the Excel window and select the Run Macro
button in the dialog box and choose the macro name, and then click on the
Run button . The power supply will reset to power on condition and then step
through the voltages in the worksheet. After each step the current is measured,
and recorded in the worksheet.
Make any changes necessary to suit your application in the “Diode’’ module.
You must enter the information in the modules exactly as shown or error will
be generated. If several system errors occur while attempting to run a macro,
you may have to reboot your PC to get the GPIB port or RS-232 port to work
properly.
Note To use the example with Window
Ò
3.1, you will need to modify the declarations at
the top of the module. Change ‘visa32.dll’ to ‘visa.dll’ in all declarations.