Computer geek, and self-appointed know-it-all, Westley Annis answers all those hard 
questions about anything related to computers and technology, as well as business and 
political questions.

What page am I on?

Question asked on August 16, 2005 11:08 PM :: :: Comments (2) :: TrackBacks (1)

Unless you live and breathe the Microsoft Word object model, it can be difficult at times to figure out where to find the values you are looking for. Word is composed of a lot of different objects, each of which have different properties, although those properties may be repeated among some objects.

In this case you are looking for page numbers. These can be found using the Information property. You supply a Word constant that specifies the type of information you want returned. In this case, you have two options that jump right out: wdActiveEndPageNumber and wdActiveEndAdjustedPageNumber.

The first option will return the actual page number, ignoring any manual adjustments to the page numbers. The first page is page one even if it prints out as page 16. The latter option will adjust the page count based on your changes. So if you've specified that the first page will print as page 16, that is the number that is returned. The second page would be 17 and so on.

Exactly how do you use the Information property?

To get the page number for the current selection:

intCurrentPage = Selection.Information(wdActiveEndPageNumber)

To get the page number for a Bookmark:

intCurrentPage = Activedocument.Bookmarks(1).Range.Information(wdActiveEndPageNumber)

There is so much more available from the Information property. You can easily tell if the current selection is inside of a table, the column and row when the selection is inside a table, header and footer type, Overtype mode, NumLock status, and more.

Categories

1 TrackBacks

Listed below are links to blogs that reference this entry: What page am I on?.

TrackBack URL for this entry: http://www.askwestley.com/cgi-sys/cgiwrap/wannis/managed-mt/mt-tb.cgi/12

» AdultFriendFinder from AdultFriendFinder

I really enjoyed your topic and plan to share your blog with my friends! thanks for taking the time out to write your blog! If you want to learn how to get 100% free access to Adult Friend Finder check out my blog! Read More

2 Comments

Peyton King said:

Hello...

I am having just a little bit of trouble with the one line of code for the page numbers...

When I use it, I seem to get all the page numbers the same which I am trying to work down, but more of an issue is that when I use it, I get Word memory errors. I have toggled this one line several times to make sure it was the actual line, and tested it with fresh reboots etc.

The only thing I can think of id maybe the information property is holding on the doc still when I go for the next one...

Any ideas would be very helpful.

I know it is strange to be using range in this way, but it seemed to be the only way I could get the type property which is not available above range. I am running this against W2K docs...

I am figuring I just adjusted incorrectly into the situation...

Thanks,
Peyton

PROC06:
If appWord.ActiveDocument.Fields.Count >= 1 Then
For Each tempRange In ActiveDocument.StoryRanges
For Each tempField In tempRange.Fields

tempPageNbr = 0
'tempPageNbr = tempRange.Information _
'(wdActiveEndPageNumber)
'Debug.Print tempPageNbr

If tempField.Type = 4 Then
' Here we kick out Index items for
' special processing...
GoSub PROC0601_NEWREC
TotalIndexItemCntr = TotalIndexItemCntr + 1
Else
' Here we grab all fields
' and stuff them in just in case...
GoSub PROC0699_NEWREC
End If
Next
Next
End If
Return

PROC0601_NEWREC:
GBLRST05.AddNew
GBLRST05!MDiitDocChapNbr = CURCHAP
GBLRST05!MDiitDocChapSubDirName = CURSUBDIR
GBLRST05!MDiitDocPath = CURDIR
GBLRST05!MDiitDocName = appWord.ActiveDocument.Name
GBLRST05!MDiitIndexItemLength = Len(tempField.Code)
GBLRST05!MDiitIndexItemPageNbr = tempPageNbr
If Len(tempField.Code) <= 255 Then
GBLRST05!MDiitIndexItem = tempField.Code
Else
GBLRST05!MDiitIndexItem = Left(tempField.Code, 255)
GBLRST05!MDiitIndexItemCat = "PROBLEM: Truncation"
GoTo PROC0601_SKIP
End If
' blah blah update blah blah
Return

Peyton King said:

I have found a way to do this using Select, but it seems to put a serious drag on the system.

I looked for an unselect. I actually get the document flashing as a translucent ghost over the immediate window...

Neat effect, but I would prefer speed, LOL...

Thanks,
Peyton

Leave a comment




Ask Westley your question on technology, business, or politics!
RDF XML
Add to My Yahoo!
Subscribe in 
NewsGator Online
Feedburner
GeoURL
Search



All Categories
Powered by
Movable Type 4.1
© 2005-2009 by Westley Annis. All Rights Reserved.

Valid XHTML 1.0!