![Rohde & Schwarz 1065.6000.20 Operating Manual Download Page 388](http://html1.mh-extra.com/html/rohde-and-schwarz/1065-6000-20/1065-6000-20_operating-manual_1477758388.webp)
FSE
Programming Examples
1065.6016.12
7.9
E-16
Visual Basic for Applications (Winword and Excel)
Programming hints:
The programming language Visual Basic for Applications (VBA) is supported as a macro language by
various manufacturers. The programs Winword and Excel use this language for the versions Winword
97 or Excel 5.0 and higher.
For macros created with Visual Basic for Applications, the same hints are valid as for Visual Basic
Applications.
Programming example:
•
Using the macro
QueryMaxPeak
a single sweep with subsequent query of the maximum peak is
performed. The result is entered in a Winword or Excel document.
Sub QueryMaxPeak()
Dim ibsta As Integer ’ Status variable
Dim iberr As Integer ’ Error variable
Dim ibcntl As Long ’ transferred characters
Dim ud As Integer ’ Unit Descriptor (handle)for instrument
Dim Response As String ’ Response string
’ Set up connection to measuring instrument
ud = RSDLLibfind("89.10.38.97", ibsta, iberr, ibcntl)
If (ud < 0) Then
Call MsgBox("Device with address 89.10.38.97 could" & _
"not be found", vbExclamation)
End
End If
’ Determine maximum peak in the range 1-2MHZ
Call RSDLLibwrt(ud, "*RST", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "INIT:CONT OFF", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "FREQ:START 1MHZ", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "FREQ:STOP 2MHZ", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "INIT:IMM;*WAI", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "CALC:MARK:MAX;Y?", ibsta, iberr, ibcntl)
Response = Space$(100)
Call RSDLLibrd(ud, Response, ibsta, iberr, ibcntl)
Response = RTrim(Response) ’ Cut off space
’ Insert value in current document (Winword)
Selection.InsertBefore (Response)
Selection.Collapse (wdCollapseEnd)
’ Terminate connection to measuring instrument
Call RSDLLibonl(ud, 0, ibsta, iberr, ibcntl)
End Sub
The entry of the peak value in the Winword document can be replaced as follows for Excel:
’ Insert value in current document (Excel)
ActiveCell.FormulaR1C1 = Response
Summary of Contents for 1065.6000.20
Page 3: ......
Page 5: ......
Page 17: ......
Page 57: ...Contents Description of Commands FSE 1065 6016 12 I 6 4 E 16...
Page 379: ...Contents Programming Examples FSE 1065 6016 12 I 7 2 E 1...
Page 391: ......
Page 393: ...Contents Maintenance and Instrument Interfaces FSE 1065 6016 12 I 8 2 E 15...
Page 419: ......
Page 421: ...Contents Error Messages FSE 1065 6016 12 I 9 2 E 1...
Page 429: ......