LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add new macro in excel

Solved!
Go to solution

The example is just a modification of the Write Table to XL example that ships with LabVIEW. It does not use the Report Generation Toolkit or any other toolkit. There will, however, be an issue with security in accessing the Visual Basic Project. I have no idea how to deal with this. I would suggest to the poster to Google for this, as this is not a LabVIEW issue, but a Microsoft Excel issue. 

 

I did make one error in the example: I forgot to wire up the filename input for the "Open Specific Workbook" VI.

0 Kudos
Message 11 of 22
(2,657 Views)

Thanks a lot for your example,

But it doesn't work for me.

I decreased the macro security level in excel to low, put the name for "open specific work book".

 

Can you explain your example ? the macro will be save in the excel work sheet?

 

I'm a bit lost !

0 Kudos
Message 12 of 22
(2,637 Views)

Try the modification attached. Note that I got this information from the web. Have you tried Google or MSDN on how to use the Excel object model?

 

As for the security, did you read the KB article that I provided in my earlier reply? In there it has a link to how to provide trust. It points to this KB article: Programmatic access to Office VBA project is denied.

 

 

NOTE: I still don't understand why you want to do it this way when you can simply call the methods and properties directly in LabVIEW. This seems like a complicated way to do it, and it requires that you mess around with the security levels in Excel, which means it's not easily portable to another computer without going in and messing around with the security settings on that computer as well. All in all, I think this is a convoluted way to do it. 

Message Edited by smercurio_fc on 06-22-2009 10:40 AM
0 Kudos
Message 13 of 22
(2,614 Views)

Hi,

 

Thanks for help.

 

i'm not an "expert" in activeX and excel but for now i just want to test your example because is that i want : 

          Send data and after run a macro, that i built in labview, in excel.

 

 So for your example, i put excel in low security and "trust into the VBA projects". after i put a root directory to a blank excel workbook.

 

But it doesn't work.

 

Plz help me with your example.

 

Thanks you.

0 Kudos
Message 14 of 22
(2,595 Views)
When I ran the example on my computer it worked. I put in the path of an existing workbook, ran the VI, leaving Excel open. The result was a new sheet in the workbook with the data, and in the VBA editor there was a new code module with the function in it. I am using Excel 2003. If you are using a different version, then I cannot say whether it will work or not.
0 Kudos
Message 15 of 22
(2,588 Views)

I have excel 2003 too. When i run the vi, i have one error :Unknown System Error in Excel Macro.vi.

And i don't know why...

Do you an idea?

0 Kudos
Message 16 of 22
(2,575 Views)
Nope, sorry.
0 Kudos
Message 17 of 22
(2,560 Views)

The only difference for me is that i use labview 8.6 and you 8.2 i believe.

 

Maybe there is a problem with this?

0 Kudos
Message 18 of 22
(2,547 Views)

The error is make at proprety node "codes panes". What is this property and what is "index"?

 

Thanks you in advance

0 Kudos
Message 19 of 22
(2,545 Views)
Solution
Accepted by kriss00
It appears that I neglected to upload the modified version. Sorry. I didn't realize you were still using the old version. Here is the modified one that I was supposed to upload in reply #13.
Message 20 of 22
(2,528 Views)