PDA

View Full Version : Letter Template Macro Issue



GSYardy
01-14-2016, 05:07 PM
I have an existing word letter template that I need to change the logo that is being used for the Header. It seems as if the logo is somehow embedded into the document and I do not know how to change it. There is no path to the existing logo that is listed in the code. "This template was created back in 2000 and has been converted over the years" I have pasted the part of the code that is referring to the header logo. Can anyone help?:ipray::ipray:

Thanks


'If E-mail Format is selected, insert graphics into first page header and footer
If boolEmailFormat = True Then
Selection.HomeKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
Selection.HomeKey Unit:=wdStory, Extend:=False
ActiveDocument.AttachedTemplate.AutoTextEntries("HeaderLogo").Insert where:=Selection.Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter
Selection.HomeKey Unit:=wdStory, Extend:=False
Selection.TypeParagraph
Selection.ParagraphFormat.SpaceBefore = 6
ActiveDocument.AttachedTemplate.AutoTextEntries("FooterLogo").Insert where:=Selection.Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Else
Selection.HomeKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter
Selection.HomeKey Unit:=wdStory, Extend:=False
Selection.ParagraphFormat.SpaceBefore = 72
End If

gmayor
01-15-2016, 06:49 AM
The code uses an autotext entry stored in the document template for each of the first page header and footer called HeaderLogo and FooterLogo. If you want to change the graphics, then recreate the autotext entries and save them in the document template.

For use in recent Word versions, change the code to
Dim oRng As Range
boolEmailFormat = True
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
If boolEmailFormat = True Then
Set oRng = ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range
oRng.Text = ""
Application.Templates(ActiveDocument.AttachedTemplate.FullName). _
BuildingBlockEntries("HeaderLogo").Insert _
where:=oRng, _
RichText:=True
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
oRng.Text = vbCr
oRng.Paragraphs(1).Range.ParagraphFormat.SpaceBefore = 6
oRng.Collapse 0
Application.Templates(ActiveDocument.AttachedTemplate.FullName). _
BuildingBlockEntries("FooterLogo").Insert _
where:=oRng, _
RichText:=True
Else
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
oRng.Paragraphs(1).Range.ParagraphFormat.SpaceBefore = 72
End If