Teledyne LeCroy USB Analyzer Automation Manual User Manual
Page 95
![background image](/manuals/353630/95/background.png)
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
95
VBA: ( MS Excel )
Public USBTracer As UsbAnalyzer
Public Trace As UsbTrace
Public GVSEngine As VScriptEngine
'
' VSEngineEventsModule is a special class implementing VSE event handlers.
' It should have, in global declaration section, a line like this:
' Public WithEvents VSEEvents As VScriptEngine
'
Dim X As New VSEngineEventsModule
Private Sub RunVScritButton_Click()
Dim VSEngine As VScriptEngine
Dim IVScript As IUsbVerificationScript
Dim ScriptName, fileToOpen As String
ScriptName = ThisWorkbook.Sheets("Sheet1").Cells(2, 2)
If USBTracer Is Nothing Then
Set USBTracer = New UsbAnalyzer
If USBTracer Is Nothing Then
MsgBox "Unable to connect to USB Protocol Suite", vbExclamation
Exit Sub
End If
End If
fileToOpen = ThisWorkbook.Sheets("Sheet1").Cells(1, 2)
Set Trace = USBTracer.OpenFile( fileToOpen )
Set IVScript = Trace 'Get the IUsbVerificationScript interface.
Set VSEngine = IVScript.GetVScriptEngine( ScriptName )
' "Subscribe" for receiving VSE events.
' the X variable ( an instance of VSEngineEventsModule class ) will handle them.
Set X.VSEEvents = VSEngine
...
VSEngine.Tag = 12 ' Assign a tag for VSE object.
VSEngine.RunVScript ' Run verification script.
Set X.VSEEvents = Nothing ' "Unsubscribe" for receiving VSE events.
Set VSEngine = Nothing ' Release external
Set IVScript = Nothing ' objects.
End Sub