03-02-2012 05:40 AM
Hi
How do i copy an excel worksheet into a different Workbook?
Solved! Go to Solution.
03-05-2012 08:26 PM
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.
03-06-2012 12:27 AM
>> 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.
03-06-2012 12:53 AM
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.
03-06-2012 01:46 AM
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.