Word VBA >> page number of the bookmark

by Jay Freedman » Sat, 07 Aug 2004 03:21:00 GMT

Hi William,

If you know the name of the bookmark, this expression gives the page number
(the underscore at the end of the first line means that the expression
continues on the second line):

ActiveDocument.Bookmarks("bkm").Range _
.Information(wdActiveEndPageNumber)

If the starting page number of the document or section has been changed from
1, then the adjusted page number (i.e., the one that would appear if you put
a {PAGE} field there) is

ActiveDocument.Bookmarks("bkm").Range _
.Information(wdActiveEndAdjustedPageNumber)


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

William wrote:
> hi,
>
> in word vba for xp, how could i find out the page number of a
> bookmark?
>
> thank you,
>
> william.




Word VBA >> page number of the bookmark

by V2lsbGlhbQ » Sat, 07 Aug 2004 03:27:03 GMT


thanks, Jay.







Similar Threads

1. Adding a page number to a bookmark

2. First page with company logo, bookmarks, other pages only bookmarks

I have a template which my program adjusts via vba for the various 
companies that use it. I need to have a first page with company logo 
followed by data which is inserted at bookmarks. Later pages would 
repeat only the inserted data at the top of the page. I'm not sure how 
to do this. Seems like the company logo etc and the data that's inserted 
at bookmarks must be in the header, but how to not repeat the company 
logo?

Before the doc is delivered to users as a finished product the dot that 
contains the custom code is defreferenced, so I can't use any vba tricks 
to show or hide in the final doc (at least that's what I understand).

Currently the header with company logo etc repeats for every page.

The bookmarks and the data that gets inserted into them are immediately 
below the header in the body of the doc and show only on the first page.

I need the data that's inserted at the bookmarks to repeat at the head 
of every page, but no the company logo etc.

I know there is a page setup option for 'different first page' but I'm 
not sure what it does, I'll be reading up on that.

3. "Insert->Page Numbers" vs "Header and Footer->Insert Page Number" - Word VBA

4. Page numbering in footers, Outside margin, Page Number + Number of Pages

5. Inconsistent Page Numbers Using Bookmark & Reference - Word Document management

6. Custom Page Numbering - Bookmarks

Hi,  I am using bookmarks to get page numbers for a TOC (for multiple reasons).
I have update fields at print turned off.
When I enter:
{ ={ PAGEREF D_Activities \h } -1}    it works fine.  When I Update Fields 
manually, it works fine (it's awesome and I'm so happy).  
At print it does one of two things:
{ =X PAGEREF D_Activities \h X -1}  (where X is actually a square box) and 
gives a Syntax error
or this  
{ ={ PAGEREF D_Activities \h }{ PAGEREF D_Activities \h } -1} and gives a 
Missing Operator error
(it's awful and I'm so frustrated)
How can I get this to print?

7. Page Numbering & Bookmarks

8. get the page number of a given bookmark

Hi all,

I am trying to get the page number of a given bookmark inserte
somewhere in the middle of a document.

Anyone could give me a clue on how to do it