Specifications
5.1.3 Microsoft Word Example
5.1.3.1 Application Configuration
Microsoft
®
Office 2000 was used for this example. This
version of Office contains Visual Basic for Applications
(VBA) which allows developers to attach Visual Basic
Macros to Word documents. The type library for the
PNA Series network analyzer should be referenced in
the Visual Basic development environment. The follow-
ing figure illustrates the reference. In this example the
“CreateObject” method will look at the configuration of
DCOM to see what machine to connect to. The code
below must be copied and placed in the Visual Basic edi-
tor for the Word document object as shown below.
5.1.3.2 Application Code
The application code is contained below. The program
inserts the data retrieved from the analyzer into a table
in a Word document. To run the application, open the
document using Microsoft Word. Enable the macros
when prompted. Once this is complete, the application
will execute and update the document. The application
can be run on a PC or the analyzer.
Option Explicit
Dim app
Dim chan
Dim meas
Dim result As Variant
Dim i As Integer
Dim num_points As Integer
Private Sub Document_Open()
' Connect to the PNA application on machine SLTSU044
Set app = CreateObject("AgilentPNA835x.Application")
' Reset the analyzer to instrument preset
app.Reset
' Create S11 measurement
app.CreateMeasurement 1, "S11", 1
' Set chan variable to point to the active channel
Set chan = app.ActiveChannel
' Set meas variable to point to the active measurement
Set meas = app.ActiveMeasurement
' Setup the channel for a single trigger
chan.Hold True
app.TriggerSignal = naTriggerManual
chan.TriggerMode = naTriggerModeMeasurement
' Make the PNA application visible
app.Visible = True
' Set channel parameters
chan.NumberOfPoints = 11
chan.StartFrequency = (1000000000#)
chan.StopFrequency = (2000000000#)
' Send a manual trigger to initiate a single sweep
chan.Single True
' Store the data in the "result" variable
result = meas.GetData(naRawData,
naDataFormat_LogMag)
' Display the result
num_points = chan.NumberOfPoints
For i = 0 To num_points - 1
ThisDocument.Tables(1).Cell(i + 2, 2).Range = result(i)
Next
Set chan = Nothing
app.Quit
End Sub
13