Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Excel Page

Excel Page

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++testingtoolstutorial
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roadme
    wrote on last edited by
    #1

    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.

    F 1 Reply Last reply
    0
    • R roadme

      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.

      F Offline
      F Offline
      freeman868
      wrote on last edited by
      #2

      _Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage =wsMysheet.GetIndex();

      freeman

      F 1 Reply Last reply
      0
      • F freeman868

        _Worksheet worksheet; Worksheets wssMysheets; . . . . LONG mTotal = wssMysheets.GetCount(); LONG mPage =wsMysheet.GetIndex();

        freeman

        F Offline
        F Offline
        freeman868
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • F freeman868

          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

          R Offline
          R Offline
          roadme
          wrote on last edited by
          #4

          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)

          R 1 Reply Last reply
          0
          • R roadme

            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)

            R Offline
            R Offline
            roadme
            wrote on last edited by
            #5

            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; }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups