Excel Page
-
Who can tell me how to get the total pages of excel when using Office Automation in VC++? _Application excel; Workbooks books; _Workbook book; Sheets sheets; _Worksheet worksheet; How can I get page for each sheet? Thank for your reply.
_Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage =wsMysheet.GetIndex();
freeman
-
_Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage =wsMysheet.GetIndex();
freeman
Sorry, I have made a mistake! _Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage = worksheet.GetIndex(); -- modified at 23:14 Wednesday 25th October, 2006
freeman
-
Sorry, I have made a mistake! _Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage = worksheet.GetIndex(); -- modified at 23:14 Wednesday 25th October, 2006
freeman
Thank freeman for your replay. Sorry I do not state very clear about my excel page. I need to know how many pages if one excel printed. So the pages should be printed pages. I know how to calculate the word pages now. But it is not the same as Excel. If I use VBA, I can use the following word to get it. pages=(sheet.hpagebreaks.count+1)*(sheet.vpagebreaks.count+1) or pages=Workbook.Excel4MacroSheets(50)
-
Thank freeman for your replay. Sorry I do not state very clear about my excel page. I need to know how many pages if one excel printed. So the pages should be printed pages. I know how to calculate the word pages now. But it is not the same as Excel. If I use VBA, I can use the following word to get it. pages=(sheet.hpagebreaks.count+1)*(sheet.vpagebreaks.count+1) or pages=Workbook.Excel4MacroSheets(50)
Here I share the function of Word pages to everybody. //This function shows how to get the pages of word int Wordpage(char* wordfile) { int page; CoInitialize(NULL); _Application app; app.CreateDispatch(_T("Word.Application")); app.SetVisible(FALSE); Documents docs=app.GetDocuments(); CComVariant FileName(wordfile); CComVariant ConfirmConversions(false); CComVariant ReadOnly(false),AddToRecentFiles(false); CComVariant PasswordDocument(_T("")),PasswordTemplate(_T("")); CComVariant Revert(false),WritePasswordDocument(_T("")); CComVariant WritePasswordTemplate(_T("")), Format(0); CComVariant Encoding(false),Visible(TRUE); CComVariant OpenAndRepair(false),DocumentDirection(false); CComVariant NoEncodingDialog(false); CComVariant XMLTransform(_T("")); docs.Open(&FileName,&ConfirmConversions,&ReadOnly, &AddToRecentFiles,&PasswordDocument, &PasswordTemplate, &Revert, &WritePasswordDocument,&WritePasswordTemplate, &Format, &Encoding, &Visible, &OpenAndRepair,&DocumentDirection, &NoEncodingDialog, &XMLTransform); _Document doc=app.GetActiveDocument(); Range rang=doc.GetContent(); page=rang.GetInformation (4).lVal;//get pages rang.ReleaseDispatch(); doc.ReleaseDispatch(); docs.ReleaseDispatch(); CComVariant SaveChanges(false),OriginalFormat,RouteDocument; app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument); app.ReleaseDispatch(); return page; }