vba to determine if there's a cover page - Word 2010

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

vba to determine if there's a cover page - Word 2010

Post by kdock »

Hey all,

I'm trying to use vba to determine if a person has inserted one of Word's cover pages into their document. If so, the code will branch. I've been less than productive searching the inet.

Despite their slickness, I don't find Word's cover pages very useful and usually avoid them. But that doesn't mean a client will.

Any help will be much appreciated.

Thanks, Kim
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: vba to determine if there's a cover page - Word 2010

Post by macropod »

Try:

Code: Select all

If InStr(ActiveDocument.Content.WordOpenXML, "<w:docPartObj><w:docPartGallery w:val=""Cover Pages""/>") > 0 Then
  MsgBox "A Cover Page has been inserted."
End If
Paul Edstein
[Fmr MS MVP - Word]

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: vba to determine if there's a cover page - Word 2010

Post by kdock »

That's perfect Paul. Thank you! K
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.