LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run vi from vba without compiling gets error 13 type mismatch

Solved!
Go to solution

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,

 

0 Kudos
Message 1 of 6
(3,026 Views)

Which line of your VBA code is generating the error?

0 Kudos
Message 2 of 6
(3,012 Views)

This line is causing problem:

 

vi.Call ParamNames, ParamVal

 

0 Kudos
Message 3 of 6
(3,005 Views)
Solution
Accepted by topic author PuddingNaicha

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.

0 Kudos
Message 4 of 6
(2,996 Views)

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,

 

0 Kudos
Message 5 of 6
(2,954 Views)
Solution
Accepted by topic author PuddingNaicha

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

0 Kudos
Message 6 of 6
(2,816 Views)