LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert strings into excel VB macro fields

Hi all,
 
I have LV7.1 and have looked at the example for adding data to excel in specific cells using ActiveX. However, my excel document (see attached print screen), contains fields belonging to a Visual Basic macro, which I now want to send data to, before I execute the macro from LV. I have been able to launch the macro, but I simply dont know how to reference the fields from Labview. Also attached is an image showing the name of the fields in VB editor, don't know if that helps...
 
Hope some kind soul can help me!
/Goran
 
 
Download All
0 Kudos
Message 1 of 7
(3,492 Views)
Check the examples. There is one that (called oddly enough Excel Macro Example.vi) that sounds like it does what you want...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(3,483 Views)
Hi Mike, thanks for helping again (last time it was Firebird/SQL with LV)!
 
I should have made it clear that I have checked that example file already. However, it only shows how to insert into normal Excel cells, not into Visual Basic macro fields in the document, which I need to do, and then run the macro. I am completely lost when it comes to VB 😞
 
 
0 Kudos
Message 3 of 7
(3,477 Views)
The way this works is that the macro is written to look for its input data in given cells on a worksheet. The LV code stuffs data into those cells and then runs the macro.

In addition, (and this is just speculation) the invoke node for the Excel Run method has a whole bunch of terminals labeled Arg1, Arg2 ... Arg30. It sort of looks like that might be a mechanism for passing data directly into a macro, unfortunately I don't have time to research it. Check out the  MS website's VBA documentation and read the docs on the VBA Run method.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 7
(3,468 Views)

Excellent tip, Mike, turns out you were guessing right. I checked this page http://msdn2.microsoft.com/en-us/library/aa220716(office.11).aspx and it feels like I am getting closer.

I have tried putting in stringdata (which is what I want to send in to the fields) through Arg1 (up to Arg4). However I get an error mesage that I have not enough arguments (Arg:s). I am as I said new to VBA. Is there anyone who could tell me how I  find out how many arguments I need to send to the VBA macro and how they should look like?

My VBA macro is attached in a text-file.

Any help is appreciated!

0 Kudos
Message 5 of 7
(3,465 Views)

GOT IT 🙂

The IT-guru at work blessed me with a short glance at the problem and gave me the answer. There were no arguments defined (I confused arguments with variables) in the first line of the script, i.e. it looked like this input_data(). With a little modification to input_data(myarg1 as string, myarg2 as string, myarg3 as string), the arguments are defined and can be sent from labview in that order and used by the VBA script.

Thanks for your help, Mike!

0 Kudos
Message 6 of 7
(3,459 Views)
Excellent!

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,456 Views)