06-12-2009 02:48 AM
Hi all,
I write in excel my data with activeX. At the end of the acquisition i want to add a new macro in excel and start it to make some graph.
How i can send to excel a complete macro?
I already know that it's possible to run a macro already present in excel and modifie it with Arg(1to30) but it not enough for me.
I simpler for me to send a complete macro.
And i don't have the office toolkits..
Thanks
Solved! Go to Solution.
06-12-2009 04:49 AM
I put my Vi in example but it doesn't work.
Someone can modifie it ?
Thanks
06-15-2009 02:28 AM
Anyone can help me?
06-15-2009 10:25 AM
Hello kriss
In the built-in LabVIEW examples is one called Write Table to XL. It will open a workbook, select a sheet, write a table, then save and close the workbook.
If you chop out the part that writes the table, you can replace it with the macro. The only function you need is the method node Application.Run. The first parameter is the name of the macro to run. All of the Argument parameters are optional.
If you do not have the Application reference convenient in your application, you can use the property node Worksheet.Application to get it.
Regards.
Romain D.
National Instruments France
06-15-2009 04:01 PM
Thanks for answer.
If i undestand all what you said, this is for run a macro already exist in the file .xls no?
I want to build my macro in labview, add and run it in excel in a new workbook.
regards
06-15-2009 05:15 PM
It appears that you are trying to add a chart to a worksheet. You can do that by calling the methods and properties directly from LabVIEW, so you do not have to resort to dynamically adding a macro. This seems to me to be a roundabout way of doing it. Several examples already exist in this forum on how to do this.
However, if you insist on doing it by dynamically adding a macro, then according to this Microsoft KnowledgeBase article, you need to access the Excel Application object's VBE property.
06-15-2009 05:38 PM
Here is the activeX code that you need to create in LabVIEW:
Application.VBE.ActiveVBProject.VBComponents.Import("test.bas")
or
Application.VBE.CodePanes(1).CodeModule.AddFromString "Dim intJack As Integer"
You may have a problem running a macro in Excel without the user allowing it unless the securty setting has been changed to low.
06-19-2009 10:40 AM
Sorry for my latest answer
Thank you for your help but i don't find the VBE application, can you send me the methode node ?
>Thanks
06-19-2009 10:59 AM
06-19-2009 01:43 PM
do you need to have the report generation toolkit to use this vi and if not what toolkit did you use
thanks,