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