I download NI-VISA 4.6.2 and wrote a VBA code to use NI-VISA to control Anritsu VNA.
my code is
status = viOpen ( defaultRM,"TCPIP::".........)
VBA program shows a compile error: Sub or Function not defined ( viOpen is highlighted)
I think I miss something in my Reference but don't know which one. I include all files seem related to NI-VISA in my reference.
Solved! Go to Solution.
VB program shows
" Sub or Function not defined " and the viOpen is highkighted.
I am not sure I link all VISA lib. How to check it ? Thanks
I know this post has 10 years, but, in fact I have the same problem.
I am not used to program using VBA in Excel, nor using VISA.
I just want to parameter my Rigol DG822 arbitrary generator.
At first, I installed the NI-VISA suite, in the VBA references, I activated VISA-COM 5.12 Type Library and VISA-COM 488.2 Formatted I/0 5.12.
My code is simply issued from the Rigol DG800 programming manual :
Dim viDefRm As Long
Dim viDevice As Long
Dim viErr As Long
Dim cmdStr As String
Dim idnStr As String * 128
Dim ret As Long
'Turn on the device, and the device resource descriptor is in CELLS(1,2) of SHEET1'
NO_LOCK, 0, "")
viErr = visa.viOpenDefaultRM(viDefRm)
viErr = visa.viOpen(viDefRm, Sheet1.Cells(1, 2), 0, 5000, viDevice)
'Send request, read the data, and the return value is in CELLS(2,2) of SHEET1'
cmdStr = "*IDN?"
viErr = visa.viWrite(viDevice, cmdStr, Len(cmdStr), ret)
viErr = visa.viRead(viDevice, idnStr, 128, ret)
Sheet1.Cells(2, 2) = idnStr
'Turn off the device'
In Cell 1.1, I have USB0::0x1AB1::0x0643::DG8A224203417::INSTR
In F8 line-debugging, it stopped at the the first VISA commande (visa.viOpenDefaultRM(viDefRm)), saying "object required / error 424".
OK, error 424, means the VISA commande is not understood. And so what do I need more than the reference activated to do that ?
In C:\Windows\System32, I have visa32.dll and visa64.dll.
But, the VISA-COM reference in VBA does not point on one of these files, but on C:\Program Files\IVI Foundation\VISA\VisaCom64\GlobMgr.dll, and I am not allowed to changed that.
May someone good help a poor crying man ?
Thank you very much for the knowledge :