09-08-2008 05:44 PM
I have an excel file containing data and some macros. I'd like to use LabVIEW to automate the pressing of a command button which has a macro assigned to it. Is there a way to do this through the ActiveX properties and methods Excel exposes?
Thanks,
Craig
09-08-2008 06:18 PM
Hi Craig,
I don't know how to automate the pressing of a command button through ActiveX properties in Excel but if you have Visual Basic you can create an exe for your excel file and call this exe with LabVIEW.
To call an exe with LabVIEW use system exec.vi
Charly
09-08-2008 06:19 PM - edited 09-08-2008 06:21 PM
09-09-2008 08:19 AM
That's a thought. An *.exe would not be the ideal case since versions of this excel file are updated by a different team of people. Perhaps there's a way to invoke a macro to run so that I can just call the macro directly since its prototype never changes?
Craig
09-09-2008 08:44 AM
Ok. I figured it out. I was asking the wrong question. I really just want to run a macro and it looks like there have been plenty of people on this forum that have asked the same thing.
Solutions:
1) LabVIEW 8.5 has some examples of calling macros (just search 'macro' in the example finder)
2) You can also use the "Run Macro VI" in the report generation toolkit
http://zone.ni.com/reference/en-XX/help/372120A-01/lvoffice/excel_run_macro/
I ended up using the example provided by NI to guide me. The Application instance has a method of "Run" which allows you to call a macro by its XLS file and name (e.g. myDoc.xls!Button_Click_1)
Thanks!
Craig