Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 02-08-2022, 10:17 PM
gmayor's Avatar
gmayor gmayor is offline VBA Insert Image(logo) into header for multiple Word Docs Windows 10 VBA Insert Image(logo) into header for multiple Word Docs Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You don't need the loop
Code:
Function ChangeLogo(oDoc As Document) As Boolean
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oShape As Shape
Const strImage As String = "D:\My Documents\My Pictures\GMLogo.png"    '"C:\lh.png"
    On Error GoTo Err_Handler
    Set oSection = oDoc.Sections.First
    ' set first section header type - may conflict with other format desires...
    oSection.PageSetup.DifferentFirstPageHeaderFooter = True
    ' put logo on first page header
    Set oHeader = oSection.Headers(wdHeaderFooterFirstPage)
    Set oShape = oHeader.Shapes.AddPicture(FileName:=strImage)
    With oShape
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
        .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
        .Left = CentimetersToPoints(-1)
        .Top = CentimetersToPoints(-0.07)
    End With
    ChangeLogo = True
lbl_Exit:
    Set oSection = Nothing
    Set oHeader = Nothing
    Set oShape = Nothing
    Exit Function
Err_Handler:
    ChangeLogo = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Header in multiple Docs ambojoy Word 1 07-03-2020 07:10 PM
VBA Insert Image(logo) into header for multiple Word Docs insert multiple word docs into main word doc MimiCush Word 4 03-26-2018 01:07 PM
VBA Insert Image(logo) into header for multiple Word Docs Change Logo in Header in many Word-Documents ika Word VBA 15 10-20-2016 11:08 PM
VBA Insert Image(logo) into header for multiple Word Docs Macro to Insert Logo in header on 1st page only and bookmark it. youseeme Word VBA 9 09-16-2016 05:25 AM
Google Docs Power Point Short cuts / Insert Image etc Rado PowerPoint 4 04-11-2014 03:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft