From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-07-2010 09:52 AM
I have a project : half part is VBA writen, half part is Labview coded. Both parts are writen to operate manually. The first one prepares data and charts them on charts sheets, the second one smooths data with ready made labview curves fitting VIs. So I want operator could use them seamless, that means calling labview from VBA 2007 code collecting X,Y data into a 2 D array, then send it to labview DLL smooth the curves and send back an array with smoothed data to excel through VBA.
My concern is how to declare 2D array parameters in VBA and in Labview in order to work fine (array of variants or doubles, parameters declared by ref or by val)
I have seen similar topics in NI forum but they dealt with VB.net and not VBA .
I run office 2007 and labview 2009 full dev. system with application builder.
Regards
06-07-2010 11:19 AM
I know that labview side there is infact a way to trigger macro's. Do you actually need to be able to interact with the folder once it is full of data?
If not then save a copy of the file as .html then you can use labview to display it too! Utterly seemless.
Although, the alternative is use one or the other. Is there a reason the whole thing cant be done in vba?
If there is then is there a reason the whole thing can't be done in labview?
I think you may be overcomplicating the program this time around.
I've been wrong before though!
06-07-2010 01:28 PM
I would agree that I would like to know more specifics as to what you're doing to see if you can handle it one environment only. That said, an alternative to using DLLs is to use the ActiveX interface for LabVIEW. Have you taken a look at this? With the ActiveX server you could do something like this in VBA:
Sub SampleArray()
Dim Data(1 To 3, 1 To 4)
Dim row As Integer
Dim col As Integer
Dim lvApp As LabVIEW.Application
Dim vi As VirtualInstrument
For row = LBound(Data, 1) To UBound(Data, 1)
For col = LBound(Data, 2) To UBound(Data, 2)
Data(row, col) = Cells(row, col)
Next col
Next row
Set lvApp = New LabVIEW.Application
Set vi = lvApp.GetVIReference("C:\temp\2D_VBA_Test.vi")
vi.FPWinOpen = True
vi.SetControlValue "Array", Data
<cleanup code here>
End Sub
(Note: cleanup code refers to closing references, etc)
06-08-2010 10:37 AM
Thank you for the answers.
The examples provided with labview for ActiveX exchanges are not very clear. I want to use labview as ActiveX server and Excel through VBA as client.
VBA code as to launch ActiveX server and as far as I am right in these sample programs it is labview Vi which launches an excel session.
I have no idea of creating and exposing classes, methods or properties needed in VBA from my Labview VI which was at the beginning a standalone application.
nice regards
06-08-2010 12:58 PM
bassevellois wrote:Thank you for the answers.
The examples provided with labview for ActiveX exchanges are not very clear. I want to use labview as ActiveX server and Excel through VBA as client.
There's only one example that I know of that ships with LabVIEW and it shows how to access LabVIEW from VB using LabVIEW's ActiveX server. It opens a VI and runs it. Doing it from VBA is very similar. You want to add the reference to the ActiveX Server in your VBA project. If you're controlling the LabVIEW development environment directly, then the library to include in your list of references will be "LabVIEW x.x Type Library". If you are controlling a LabVIEW-build app, then the library name will be whatever you specified when you built the app.
I have no idea of creating and exposing classes, methods or properties needed in VBA from my Labview VI which was at the beginning a standalone application.
I don't quite understand what you are referring to. The ActiveX Server in LabVIEW and a LabVIEW-built app are pre-defined. You do not export anything from your LabVIEW VI. The available properties and methods are a function of the LabVIEW ActiveX Server, not of your VI. If you are building an app then you just need to enable the ActiveX server for the application, and that's done in the build specification.
How to reproduce my example:
06-09-2010 03:17 PM
Thank you smecurio_fc but I can't open the Xl workbook, Excel tells me the file is corrupted (the macro code module concealed in the workbook is not loaded when Excel fixes it) .
May you try if you can to save it in new Excel binary format xlsb.
regards
06-09-2010 03:34 PM
Smercurio's .xls file opens just fine for me.
Perhaps it is a security setting you have set in Excel that prevents you from opening files with macro code.
I don't know what the "new Excel binary format xlsb" you are talking about is. Whatever it is sounds extremely proprietary and unlikely that most Excel users would be able to open it.
06-09-2010 03:50 PM
06-10-2010 01:49 AM
It's allright now on another PC which warned me of security settings then I turned them to low But it is weird for my own PC on which I work on VBA modules coding, security settings are turned low by default. Now it doesn't matter I have saved it and have sent it by email to my own PC and it works fine
Thank you for your help and I will work around to adapt it to my concern
06-10-2010 10:13 AM
Now it is an other question about the same ActiveX Vi compiled as an exe for installing on few computers : How can I call it from VBA because it has no more the .VI extension (of course it is exe) and it is not seen by VBA as labview component with all its properies and so on.
What is the trick ?
I have tried to find out this afternoon but I have found not a single bit of information on the subject.
Regards