Determine if a Footer exists in Word document?

  • Thread starter Brian McCullough
  • Start date
B

Brian McCullough

Hello,

What is the correct way to determine if a footer exists in a Word document
(using Word 2002 through Word 2007))?

Essentially, when a document opens, I need to insert a footer on all pages
in the document, but only if a footer doesn't already exist...

Bonus question...how do I do this in Excel and PowerPoint?

TIA!!

-Brian
 
C

Cindy M.

Hi Brian,
What is the correct way to determine if a footer exists in a Word document
(using Word 2002 through Word 2007))?

Essentially, when a document opens, I need to insert a footer on all pages
in the document, but only if a footer doesn't already exist...
Well, basically you access the header/footer object then query its
content/length. An "empty" header or footer will have a length of 1, a
paragraph mark (ANSI 13). Example

Len(ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range)

Keep in mind that a document could have multiple headers/footers. Each
section will have one, and each section could have a maximum of three
headers and three footers. If you could be dealing with documents of that
sort, you'll want to work through all the sections and check the three types
of headers and footers. There's an Exists property for "Different First
Page" (that tells you whether the option is activated, not whether it
contains anything) and for "Odd and Even" you have to check the
OddAndEvenPagesHeaderFooter property of the PageSetup object (this will
pertain to the entire document).

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top