06-19-2002 01:47 PM
06-20-2002 04:31 PM
06-21-2002 06:56 AM
06-21-2002 08:29 AM
06-21-2002 08:48 AM
06-21-2002 04:28 PM
06-24-2002 05:53 AM
07-29-2011 11:13 AM
I need to make a copy of the worksheet so I can use for pasting to another workbook (or to the same worksheet) in the same Excel application.
But, I am stuck with the following code. I can't seem to get a copy of the worksheet. Could you please show me how you did it or
check what I did wrong. Below are my code.
if (FileSelectPopup ("", "Sheet1.xls", "Sheet1.xls", "", VAL_LOAD_BUTTON, 0, 0, 1, 0, excelFileName))
{
SetCtrlAttribute (panelHandle, PANEL_CLOSEDATABUTTON, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_OPENDATABUTTON, ATTR_DIMMED, 1);
//Create Excel.Application instance
errStatus = Excel_NewApp (NULL, 1, LOCALE_NEUTRAL, 0, &excelAppHandle);
//Make Excel visible
errStatus = Excel_SetProperty (excelAppHandle, NULL, Excel_AppVisible, CAVT_BOOL, VTRUE);
//Do not display alert when document is closed without saving
errStatus = Excel_SetProperty (excelAppHandle, NULL, Excel_AppDisplayAlerts, CAVT_BOOL, VFALSE);
//Acess Work books handle and open the selected file.
errStatus = Excel_GetProperty (excelAppHandle, NULL, Excel_AppWorkbooks, CAVT_OBJHANDLE, &excelWorkbooksHandle);
errStatus = Excel_WorkbooksOpen (excelWorkbooksHandle, NULL, excelFileName,
CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL,CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL,&excelWorkSheetHandle);
//Copy WorkSheet
errStatus = CA_VariantSetObjHandle (&Sheet1, excelWorkSheetHandle, CAVT_DISPATCH);
errStatus = Excel_WorksheetCopy (excelWorkSheetHandle, NULL,CA_DEFAULT_VAL, Sheet1);
//Discard unwanted handle CA_DiscardObjHandle (excelWorkSheetHandle);
}
Thanks,
08-04-2011 03:28 PM
ACNI
You will probably want to start a new thread. The original thread is 7 + years old. Old threads usually don't get as much attention even though they get bumped to the top of the forum. Always make a new post for a different problem (even if related to this topic). My 2 cents.
Greg