PDA

View Full Version : page number



andalusia
06-15-2006, 01:34 PM
Is there an expression that returns the current page number of where the selection is located?

I wish to have logic detect the page number that the user is on and perform tasks based on this value.

Help would be appreciated.

mdmackillop
06-15-2006, 02:53 PM
Hi Andalusia,
Welcome to VBAX.
Have a look at "Information Property" in VBA help. If you need more, please let us know.
Regards
MD

fumei
06-15-2006, 04:39 PM
Just be aware that "page" number in Word is a slippery thing. It is very possible to get a number that is not precisely what you think it is. Page numbers in Word are always calculated (derived) - they are NOT fixed things.

andalusia
06-17-2006, 11:26 AM
Hi Andalusia,
Welcome to VBAX.
Have a look at "Information Property" in VBA help. If you need more, please let us know.
Regards
MD

What version of Word/VBA is that found in? I don't see it in mine.

mdmackillop
06-17-2006, 11:30 AM
Word 2003.

Returns information about the specified selection or range. Read-only Variant.
expression.Information(Type)
expression Required. An expression that returns one of the objects in the Applies To list.
Type Required WdInformation (mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1033\vbawd10. chm::/html/woproInformation1.htm#). The information type.


Example (http://www.vbaexpress.com/forum/)

This example displays the current page number and the total number of pages in the active document.
MsgBox "The selection is on page " & _ Selection.Information(wdActiveEndPageNumber) & " of page " _ & Selection.Information(wdNumberOfPagesInDocument) If the selection is in a table, this example selects the table.
If Selection.Information(wdWithInTable) Then _ Selection.Tables(1).Select This example displays a message that indicates the current section number.
Selection.Collapse Direction:=wdCollapseStartMsgBox "The insertion point is in section " & _ Selection.Information(wdActiveEndSectionNumber)

fumei
06-17-2006, 03:33 PM
All versions (2000 onwards) have VBA Help...but it is NOT a default install. You must explicitly install VBA Help.

andalusia
06-17-2006, 03:42 PM
Information Property is an entry in my help. I am running Word 2002. However, when I Used the Microsoft visual Basic Help, and the paper clip asked me what I would like to do, putting Information Property here did not work. It gave the following results:

Type Property
Tag Property
ShadowFormat Object
ExtraInfoRequired Property
FreeFormBuilder Object
System Property
Footers Property
LookupNameProperties Method
SplitSpecial Property

I don't think I'm using the Help correctly, because I have had problems like this before. The way that I found it was to tell the paperclip:

Selection.Information

and this brought up Information Property as one of the choices.

mdmackillop
06-17-2006, 03:47 PM
Personally, I've never found paper clips to be a reliable source of information :whistle:

Try wdinformation

fumei
06-17-2006, 03:47 PM
Get rid of that stupid paper clip. Aaaaaarrrrgggghhhh.

Are you in the VBE (Visual Basic Editor)? If so, then I hope you have ALL options for the editor (Tools > Options) checked. Now you can type in a code module

Say Selection - and press F1 (Help).