I'm attempting to talk with various instruments (tektronix, Agilent etc.) using VB in excel, using this as a starting point:
I have no problem communicating with the scope using the Tektronix excel add-in, to send and receive data, however the
Agilent VB code hangs during initialization. I want to be able to communicate with other instruments so need a more
generic and flexible method, so I'm giving VB a try.
Using the Agilent code in the spreadsheet (2nd version below), I'm getting the following error when I click the Start button "An IO error occured: HRESULT =
80040011" This code appears to be a "OLE_E_CANTCONVERT code meaning Not able to convert object.
In the Agilent/Youtube example shown in the video the init code is as follows:
Public Sub Intialize_Click()
On Error GoTo ioError
instrAddress = Range("B4").Value
Set ioMgr = New VisaComLib.ResourceManager
Set instrAny = New VisaComLib.FormattedIO488
Set instrAny.IO = ioMgr.Open(instrAddress)
Exit Sub
ioError:
MsgBox "An IO error occured:" & vbCrLf & Err.Description
End Suband the code in the supplied spreadsheet is slightly different:
Public Sub Intialize_Click()
On Error GoTo ioError
instrAddress = Range("B4").Value
Set ioMgr = New VisaComLib.ResourceManager
Set instrAny = New VisaComLib.FormattedIO488
Set instrAny.IO = ioMgr.Open("DMM3")
Exit Sub
ioError:
MsgBox "An IO error occured:" & vbCrLf & Err.Description
End SubThe 3rd Set instruction is the one causing the error.
The 2nd version creates the HRESULT = 80040011 error, and the first version, causes excel to outright crash requiring a restart.
Does anyone have any insight or have experience communicating with an USB based Tektronix instrument from
excel using VB?
The excel file is available here:
https://community.keysight.com/thread/21917