LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Excel worksheet to a different Workbook

Solved!
Go to solution

Hi

 

How do i copy an excel worksheet into a different Workbook?

Help share your knowlegde
0 Kudos
Message 1 of 5
(3,834 Views)

Hi Shako,

 

Can you give a few more details about what you are trying to do? Do you have two different Excel files and are you trying to copy a worksheet from one to another? Are you copying just the data values in the cells or are you copying formulas, formatting, etc.?

 

The Developer Zone article Generating Microsoft Excel Reports with LabWindows/CVI demonstrates how to open an excel document, select different worksheets and manipulate the data in them so it should provide a good starting point for what you are trying to accomplish.


Milan
0 Kudos
Message 2 of 5
(3,813 Views)

>> Do you have two different Excel files and are you trying to copy a worksheet from one to another?

This is what im trying to do.

 

More information on my program.

What i got so far is , i take a format text file which contain text values and units.

I then decoder the text file and place its into a template excel file.

What i would like is to give the user a choose to save this template sheet, which i have editted, into an existing excel file of there choice .

 

I got the basic read and write and even registering OnSelectionChangeCallbacks.

I just can for the life of me get the sheets to copy.

Help share your knowlegde
0 Kudos
Message 3 of 5
(3,807 Views)
Solution
Accepted by topic author Shako

Found a solution.

 

CA_VariantSetObjHandle (&sheet1, WorkSheetHandle2, CAVT_DISPATCH);
Excel_WorksheetCopy (WorkSheetHandle1, NULL,CA_DEFAULT_VAL,sheet1);

 

This seems to be working.

 

But now i cant get the Excel.exe to quit.

I discard all CAObjHandles and call this "ExcelRpt_ApplicationQuit (AppHandle)" before i discard the App Handle.

 

Help share your knowlegde
0 Kudos
Message 4 of 5
(3,803 Views)

I Found out why i could quit the application.

 

When i used the following i did realise this Variant (sheet1) needed to be cleared aswell.

CA_VariantSetObjHandle (&sheet1, WorkSheetHandle2, CAVT_DISPATCH);

 

So i used "CA_VariantClear (&sheet1); " and discard all other handles and presto it quit the excel application.

Help share your knowlegde
0 Kudos
Message 5 of 5
(3,800 Views)