LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass parameters into an executable from VBA

I've seen the example in ...\examples\comm\freqresp.xls on how to use activex to open and run a labview vi.  What I'm interested in is opening and running a labview exe.  I've used the shell("pathtoexe.exe") to successfully open the exe, but I can't figure out how to change the control values on the front panel and run the exe like the example shows for the vi.  Any suggestions?
0 Kudos
Message 1 of 7
(4,201 Views)
Search in the example finder for command line. This will help you.

Greets, Dave
Greets, Dave
0 Kudos
Message 2 of 7
(4,186 Views)
So you are suggesting to pass it through as command line arguments?  I've done that before, but when I saw that excel could set the values of controls in vis, I thought it might be possible to do the same thing in an exe.  Should I assume it isn't?
0 Kudos
Message 3 of 7
(4,177 Views)
It is possible without using the command line arguments. I don't know the eample you mention but to use the ActiveX properties and methods of a built LabVIEW exe, when you build it, you have to first enable it as an ActiveX server. I don't know where this is set with the 8.x app builder but in older versions it is on the application settings tab. After the app is built, instead of the LabVIEW application reference when controlling VIs, you use the application reference of your new exe file.
Message 4 of 7
(4,173 Views)

Dennis,

This is what I'm after, but I'm having a slight problem.  After building the exe like you said, and adding it as a reference in excel's vba, I come across an error in my code.

Sub LoadData()

Dim frapp As FrequencyResponse.Application
Dim vi As FrequencyResponse.VirtualInstrument
Dim paramNames(4), paramVals(4)

Set frapp = CreateObject("FrequencyResponse.Application")
vipath = "C:\Program Files\National Instruments\LabVIEW 7.1\examples\apps\Frequency Response.exe"
Set vi = frapp.GetVIReference(vipath)

Everything works, but when I get to the last line of "Set vi =..." it returns the error, unexpected file type.  Is this because it is calling an exe and not a vi?  Any help would be greatly appreciated.

I've made this code by following the afore mentioned example, but using the Frequency Response activex controls.

0 Kudos
Message 5 of 7
(4,165 Views)

I was afraid you were going to ask me a VB question. Smiley Sad I haven't done any VB programming in a long time and I've only tried to control a LabVIEW exe from a LabVIEW VI. The only thing I can think of at the moment is to make sure the app you created is registered as an ActiveX server. Here's an older post that mentions how to do it and also has an Excel macro that might help.

http://forums.ni.com/ni/board/message?board.id=170&message.id=127040&query.id=268934#M127040

Message 6 of 7
(4,158 Views)
Awesome.  Thanks Dennis, that is just what I was looking for but couldn't find.  It works now.
0 Kudos
Message 7 of 7
(4,154 Views)