Application Programs 6
Keysight 34970A/34972A User’s Guide 255
Example Programs for Excel 7.0
This section contains two example programs written using Excel macros (Visual
Basic® for Applications) to control the 34970A/34972A. Using Excel, you can
send SCPI commands to configure the instrument and then record measurement
data on the Excel spreadsheet.
To write an Excel macro you must first open a module in Excel. Go to the Insert
menu, choose Macro, and then Module. Name this module “Send Commands” by
clicking on the tab with the right mouse button. Create another module and name
it “Port Configuration”. You will use the “Port Configuration” module to configure
all of the overhead required to communicate with the instrument over the
interface. You will use the “Send Commands” module to send the SCPI commands
to the instrument using the “Port Configuration” module.
Two Excel examples are included in this section. To enter the first example
(“takeReadings”), type the text as shown on page 256 into the “Send Commands”
module. Then type the text for configuring the interface as shown on page 258
into the “Port Configuration” module.
After entering the information for both modules, go to a spreadsheet and run the
example program. Note that you must run the macro from a spreadsheet. With the
cursor in the spreadsheet, select Macro from the Tools menu. Then double-click
on the “takeReadings” macro in the Macro dialog box.
To run the second example (“ScanChannels”), type the text as shown on page 260
into the “Send Commands” module and reuse the “Port Configuration” module
from the first example (page 258).
Make any changes necessary to suit your application in the “Send Commands”
module. You must enter the information in the modules exactly as shown or an
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 to work properly.
To use these examples with Windows 3.1, you will need to modify the
declarations at the top of the “Port Configuration” module. Change visa32.dll to
visa.dll in all declarations.