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. How to automate word to go to first/last page of the document?

How to automate word to go to first/last page of the document?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondelphitutorial
2 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    sashoalm
    wrote on last edited by
    #1

    In my app I automate word. In my main window I have buttons for going to first/prev/next/last page. When the user clicks on them I want to make word programatically go to the page. I do this for prev/next

    m_Application.CreateDispatch("Word.Application");
    .......
    m_Browser.AttachDispatch(m_Application.get_Browser());

    .......
    // on prev
    void CMyView::OnPagesGoToPrevious()
    {
    m_Browser.Previous();
    }

    // on next
    void CMyView::OnPagesGoToNext()
    {
    m_Browser.Next();
    }

    But there are no methods for going to first/last page. How do I implement it?

    There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

    G 1 Reply Last reply
    0
    • S sashoalm

      In my app I automate word. In my main window I have buttons for going to first/prev/next/last page. When the user clicks on them I want to make word programatically go to the page. I do this for prev/next

      m_Application.CreateDispatch("Word.Application");
      .......
      m_Browser.AttachDispatch(m_Application.get_Browser());

      .......
      // on prev
      void CMyView::OnPagesGoToPrevious()
      {
      m_Browser.Previous();
      }

      // on next
      void CMyView::OnPagesGoToNext()
      {
      m_Browser.Next();
      }

      But there are no methods for going to first/last page. How do I implement it?

      There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      I did a quick check to see what Word (V12) would do if I recorded the 'keyboard equivalent' methods as a macro, and it put this Selection.EndKey Unit:=wdStory (for Control-End, go to end of (document?) ) in the macro and this Selection.HomeKey Unit:=wdStory for Control-Home to go to the start of the (document?) So maybe you need to start with a Selection Object .. the MSDN references are a pita though - I couldnt make head nor tail looking at this ... http://msdn.microsoft.com/en-us/library/bb288734(v=office.12).aspx[^] good luck

      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