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 / February 2008

Tip: Looking for answers? Try searching our database.

wdHeaderFooterFirstPage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bret Thompson - 13 Feb 2008 23:03 GMT
I am ugrading to Office 2007, from 2000.  This line of code used to work. It
would put my letterhead image in the First Page Header.  In Work 2007, it
goes into the regular header, instead of the First page header.

Set oNewLetterHead =
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes.AddPicture(FileName:=Options.DefaultFilePath(Path:=wdUserTemplatesPath)
& "\LetterHead-pg1.wmf", LinkToFile:=True, SaveWithDocument:=True)

The problem seems to be with the "Headers(wdHeaderFooterFirstPage)" section,
but I don't know what else to try.  According to all of the documentation,
this should be putting the picture (shape) in the first page header.

Any help would be great.

Thanks
Bret
Doug Robbins - Word MVP - 14 Feb 2008 01:51 GMT
Other people seem to have had the reverse problem - wanting it in the
Primary Header and it ending up in the First Page Header and it seems to be
caused by  the image being inserted as an InlineShape.

A couple of fellow MVP's collaborated on the following code as a workaround:

Sub ConvertInlineShapeToShape()
Dim rngShape As Range
Dim rngNewShape As Range
Dim oInlineShape As InlineShape
Dim oShape As Shape

With ActiveDocument.Sections.First
 'get the inlineshape from the primary header
 Set oInlineShape = _
   .Headers(wdHeaderFooterPrimary).Range.InlineShapes(1)
 'Temporarily move the inline shape to the first page header
 Set rngShape = _
   .Headers(wdHeaderFooterFirstPage).Range
 rngShape.Collapse
 rngShape.FormattedText = oInlineShape.Range.FormattedText
 'delete the inline shape from the primary header
 oInlineShape.Delete
 'convert the moved inline shape to a shape
 Set oInlineShape = _
   .Headers(wdHeaderFooterFirstPage).Range.InlineShapes(1)
 Set oShape = _
   oInlineShape.ConvertToShape()
 'Copy the converted shape back to the primary header
 Set rngShape = _
   oShape.Anchor
 Set rngNewShape = _
   .Headers(wdHeaderFooterPrimary).Range
 rngNewShape.Collapse
 rngNewShape.FormattedText = rngShape.FormattedText
 'delete the temporary shape from the first page header
 oShape.Delete
End With

End Sub

Maybe however you can just change your code to put it in the PrimaryHeader
instead of the FirstPageHeader and you may then get it where you want it.
Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am ugrading to Office 2007, from 2000.  This line of code used to work.
>It
[quoted text clipped - 14 lines]
> Thanks
> Bret
 
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.