LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Insert worksheet

I am having trouble trying to insert an excel worksheet from one workbook into another workbook. None of the excel functions seem to work for me and I am having a problem trying to find a good example. Basically what my program does is it will collect temperature data from an appliance over an hours time and then spit this data to an excel template which already has an implemented graph and a formula chart. The graph that I am using is an older excel graph which cannot be changed. After the data is added to the excel spreadsheet, the excel graph will update with the new data and I run a few macros to process the data and save to the formula chart. The issue though is, I don't know upfront how many tests I need to run so I want to add a spreadsheet template (which has the embedded graph and chart) to the end of the workbook and follow the same data process from above. This will happen for as many tests as I need to run. Can anyone help me with this issue.

0 Kudos
Message 1 of 11
(3,541 Views)

I'm working on the attached vi, which in its current state will copy a sheet from an excel file to another bringing along the formatting, etc.  It copies fine, however I'm having trouble closing out Excel after the vi executes (which isn't a huge problem but I would like to solve it).  

 

Can anyone shed some light as to why that is happeining?

0 Kudos
Message 2 of 11
(3,538 Views)

I can't open your VI since I'm using LV2009 but the way to close Excel is to use the _Application Quit method.

 

Ben64

0 Kudos
Message 3 of 11
(3,535 Views)

Isn't that what this is?  Or am I using it in a wrong way?

0 Kudos
Message 4 of 11
(3,532 Views)

We can't see from your picture what is referenced to the _Application quit method and also why you are using it twice. Is there an error reported?

 

Ben64

0 Kudos
Message 5 of 11
(3,526 Views)

I've opened 2 excel references, the original where I'd like the second excel sheet to merge into, and the one with the sheet to be merged.  Attached should be the whole vi so you can get a better idea.

 

Edit:  I do not get an error reported

0 Kudos
Message 6 of 11
(3,523 Views)

Would it work to open Excel once, and choose different workbooks within that (for the different files)?  This is my first project with activeX so I have a bit of a learning curve, and I do appreciate the help.

0 Kudos
Message 7 of 11
(3,518 Views)

I think you should definitely use only one Excel._Application reference. A difference I noted is that in one of my vi I use the  _Workbook.Close method before closing the application.

 

Ben64ProjectView002.png 

0 Kudos
Message 8 of 11
(3,514 Views)

Thanks for the help ben64.  I've revised it to use only one Excel._Application reference, and added the _Workbook.Close method, but Excel stays open as one of the processes (the application itself is hidden).  Still works like a charm, just doesn't want to close out of Excel.

 

 

0 Kudos
Message 9 of 11
(3,506 Views)

Are you sure there is no error reported in the error cluster?

 

Ben64

0 Kudos
Message 10 of 11
(3,503 Views)