Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Ask Word whether first page header of a section is on an odd page?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 27 Dec 2006 07:51 GMT
Hello,

I got a long word document with several sections, each section with
different first page header and different headers for odd and even
pages.

Can Word VBA tell me whether the first page header of a given section
is on an even (or odd) page, so that a boolean value is returned (True
or False)?

Help is appreciated. Thank you in advance.

Regards,

Andreas
Cindy M. - 27 Dec 2006 10:20 GMT
Hi Andreas,

> I got a long word document with several sections, each section with
> different first page header and different headers for odd and even
[quoted text clipped - 3 lines]
> is on an even (or odd) page, so that a boolean value is returned (True
> or False)?

Word can't tell you that directly. But you can calculate it. Example:
Sub CalculateEvenOddPageSectionStart()
   Dim rng As Word.Range
   Dim sec As Word.Section
   
   'Loop through all the sections in the current doc
   For Each sec In ActiveDocument.Sections
       Set rng = sec.Range
       'Get the start of the section
       rng.Collapse wdCollapseStart
       'MOD gets the remainder after dividing with 2
       'If it's 0, then it's an even page number
       If rng.Information(wdActiveEndAdjustedPageNumber) Mod 2 = 0 Then
           MsgBox "Section " & sec.Index & " starts on an even page"
       Else
           MsgBox "Section " & sec.Index & " starts on an odd page"
       End If
   Next
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.