Select a page

P

pk

Hello again. FYI - I am automating Word from Excel.

I have the following function that is supposed to select a
specific page in a document, it works well, unless the
target page is the LAST page in the document:

Dim wrdApp As Word.Application
Set wrdApp = GetObject(, "Word.Application")

wrdApp.Documents(argFileName).Activate
With wrdApp.Selection
.ExtendMode = False
.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Name:=argPageNumber
.ExtendMode = True
.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1 ',
Name:=""
.ExtendMode = False
End With

Can someone tell me what is wrong or how I can always
concisely select an entire page no matter where it is in
the document? Your example code is most appreciated.
Thanks much in advance.
 
J

Jonathan West

Hi pk

this should do the trick

Dim wrdApp As Word.Application
Set wrdApp = GetObject(, "Word.Application")

wrdApp.Documents(argFileName).Activate
wrdApp.ActiveDocument.Bookmarks("\Page").Range.Select
 
T

Tommy Svensson

Hi,

I would like a button to behave like this: copy the entire CURRENT page
(with graphics, charts, tables and everything) and insert a copy of it
immediately after the CURRENT page.

How can this be done?

Thx for a great forum!!!

You may very well reply directly to me.

/Tommy

Hi pk

this should do the trick

Dim wrdApp As Word.Application
Set wrdApp = GetObject(, "Word.Application")

wrdApp.Documents(argFileName).Activate
wrdApp.ActiveDocument.Bookmarks("\Page").Range.Select
 
J

Jonathan West

Hi Tommy

Try this

ActiveDocument.Bookmarks("\Page").Range.Select
Selection.Copy
Selection.Collapse Direction:=wdCollapseEnd
Selection.Paste

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup
 
J

Jonathan West

Tommy Svensson said:
Hi,

I would like a button to behave like this: copy the entire CURRENT page
(with graphics, charts, tables and everything) and insert a copy of it
immediately after the CURRENT page.

How can this be done?

Thx for a great forum!!!

You may very well reply directly to me.

/Tommy

Hi pk

this should do the trick

Dim wrdApp As Word.Application
Set wrdApp = GetObject(, "Word.Application")

wrdApp.Documents(argFileName).Activate
wrdApp.ActiveDocument.Bookmarks("\Page").Range.Select

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top