03-17-2010 06:36 PM
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.
Thanks
Solved! Go to Solution.
03-18-2010 05:00 AM
03-18-2010 12:18 PM
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
03-18-2010 06:42 PM
03-19-2010 03:09 AM
11-21-2020 09:02 AM
Hello,
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 :
Sub QueryIdn()
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'
visa.viClose (viDevice)
visa.viClose (viDefRm)
msg.Close
End Sub
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 :
Best regards
Fred8
02-22-2022 03:34 PM
I also ended up in exactly the same situation with a slightly different model.
The issue seems to be some changes in the NI VISA API, so VBA does not work anymore.
Any suggestions on how to use the API would be appreciated. Thanks.
Zoltan
02-23-2022 08:35 AM
As it seems this API is completely abandoned / probably never worked / definitely not easy to use -if a standalone software is suitable, then I would recommend to use UlterPower from the Rigol website: https://www.rigolna.com/download/
I saw some reported problems with it, but worked for me.
02-23-2022 07:25 PM
Hello. ZoltanMTS.
The Excel VBA measurement program I created still works with NI-VISA.
It works fine with the latest NI-VISA 21.5 as of today.
Please note that if you are using Microsoft 365, there is a version that does not work due to a bug on the Office side, so you need to update to 16.0.14827.20192 or higher.
https://docs.microsoft.com/en-us/officeupdates/update-history-office-2019
02-27-2022 01:17 PM
Hi Iwa6,
Thanks for your reply. This is a problem I face quite frequently: there is a nice software, which I would like to use, but I cannot make it work and I cannot find information about restrictions or incompatibilities.
I appreciate, there are too many versions to test for incompatibilities, but it is frustrating for the users / developers to face this kind of problems.
I saw I was not the only one with this problem, that is why I sent out a new message.
Thanks to clarify it, it may be useful for someone else in the future.
Zoltan