Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Page Numbers

Status
Not open for further replies.

ratman

Technical User
Jun 26, 2000
143
US
This is as far as I've got so far.....I need to return only the page numbers from certain panes in a word file....but this returns the entire header.

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection.HeaderFooter.PageNumbers
pg = .Parent
End With

Thank you

 
Not sure what you need but this may help

Dim oPageNoField As PageNumber

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

For Each oPageNoField In Selection.HeaderFooter.PageNumbers
With oPageNoField
.Select
Debug.Print Selection.Text
End With
Next oPageNoField
 

With ActiveWindow.ActivePane.Selection
.Collapse wdCollapseStart
MsgBox .Information(wdActiveEndPageNumber)
End With

M :)
 
Thank you both Justin and Mossoft.

I ended up using this:

Set myrange = ActiveDocument.Content
myrange.Select
curpage = myrange.Information(wdActiveEndPageNumber)

Thanks again to both of you.
 
Why do my MicrosoftWord Selection statements cause a runtime error EVERYTIME ?
I am running a macro from an Excel file.
I open Word like this:

Set fileWord = appWord.Documents.Open(fn) ' fn=filename
Application.ActivateMicrosoftApp xlMicrosoftWord
appWord.Visible = True
ActiveDocument.Words(39).Select
cuspn = ActiveDocument.Words(39).Text

then the error occurs here...even though I can see the highlighted Selected word.

Selection.Find.ClearFormatting
With Selection.Find
blahblahblah
End With


 
try

appWord.Selection.Find.ClearFormatting
With appWord.Selection.Find
blahblahblah
End With


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top