Consulting

Results 1 to 2 of 2

Thread: Letter Template Macro Issue

  1. #1
    VBAX Newbie
    Joined
    Jan 2016
    Posts
    1
    Location

    Letter Template Macro Issue

    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?

    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


  2. #2
    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •