LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add new macro in excel

Solved!
Go to solution

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

0 Kudos
Message 1 of 22
(4,323 Views)

I put my Vi in example but it doesn't work.

Someone can modifie it ?

 

Thanks

0 Kudos
Message 2 of 22
(4,315 Views)

Anyone can help me?

0 Kudos
Message 3 of 22
(4,285 Views)

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.

0 Kudos
Message 4 of 22
(4,273 Views)

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

0 Kudos
Message 5 of 22
(4,261 Views)

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. 

0 Kudos
Message 6 of 22
(4,250 Views)

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.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 7 of 22
(4,247 Views)

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

0 Kudos
Message 8 of 22
(4,190 Views)
It's not a method, but a property. See attached partial example that uses the second of the mentioned ways.
0 Kudos
Message 9 of 22
(4,187 Views)

do you need to have the report generation toolkit to use this vi and if not what toolkit did you use

 

thanks,

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 10 of 22
(4,177 Views)