03-05-2014 07:18 PM
Hi,
I'm trying to use VBA code to access Agilent 33250A vi driver. I follow examples in the forums but I'm not quite sure why I'm getting 'Run Time error 13' type mismatch.
Sub LabVIEW()
Dim filepath As String
Dim lvapp As Application
Dim vi As VirtualInstrument
Dim ParamNames(0 To 1) As String
Dim ParamVal(0 To 1) As Variant
Set lvapp = CreateObject("LabVIEW.Application") 'create connection to labview
filepath = "C:\Program Files\National Instruments\LabVIEW 2013\instr.lib\Agilent 33XXX Series\Public\Action-Status\Enable Output.vi"
Set vi = lvapp.GetVIReference(filepath) 'load vi
ParamNames(0) = "VISA resource name"
ParamNames(1) = "Enable Output (T: Enable)"
ParamVal(0) = "GPIB0::10::INSTR"
ParamVal(1) = True
vi.FPWinOpen = True
vi.Call ParamNames, ParamVal
lvapp.Quit
End Sub
Any suggestions?
Thanks,
Solved! Go to Solution.
03-05-2014 07:45 PM
Which line of your VBA code is generating the error?
03-05-2014 07:50 PM
This line is causing problem:
vi.Call ParamNames, ParamVal
03-05-2014 08:14 PM
I've never called LabVIEW from VBA. But I do know LabVIEW and I do know VBA.
I see one of two possibilities
1. Either the string for the resource name doesn't work for the VISA resource parameter, or the Enable parameter doesn't like the True.
2. Are there more input controls? Do you need to assign a parameter and a value for every control on the Agilent VI? I don't know. Perhaps the VI just assumes the defaut just like if you didn't put a wire into a subVI.
For #1. Break the code smaller. First just do the VISA resource and comment out the Enable parameter and value. Then try again with the VISA resoure and value commented out and assign the Enable to parameter(0) and value(0).
See if which one or if both of those still trigger the error.
03-07-2014 05:10 PM
So
Either way I get the following message: "run-time error '5001': Labview: paramNames type mismatch. Expected 1D array of string or 1D array of string variants.
Looks like I must include an array but still no way of finding out which one is causing the issue.
I also tried provind all the input including "error in" but I'm still getting the same error. If I enter the Param Name incorrect, I would get message that tells me "VISA resource" is a require input so I kind of know that the application is being linked. Anything else might be good to try?
Thanks,
09-03-2014 12:00 PM
Hi, All,
I think I eventually found out that my software wasn't updated. So updating the VISA software probably would have fixed everything. Not sure because I went the other route and decided to pack my vi into a .exe and it is a lot easier to call .exe from VBA then calling vi from VBA.
Thanks,
Melody