#1
|
|||
|
|||
Replace Header Picture
Currently I have code which will find and replace (using excel doc) text in body, Headers and Footers.
I also need a to have a picture/ Logo replaced only in the first section of the header for multiple documents. I know I have to use .Shapes & .inlineshapes however, I have confused on the logic on how to implement this as many forums on the issue deal with either deal with on doc at a time or adding or deleting a picture separately or using old code which I am not too sure is compatible/ valid. Could anyone explain how this would work? |
#2
|
|||
|
|||
Run the following as a custom procedure using my Batch Process documents add-in http://gregmaxey.com/word_tip_pages/...der_addin.html:
Code:
Function ChangeLogoPicture(ByRef oDoc As Word.Document) As Boolean Dim oHeader As HeaderFooter Dim oRng As Range, oRngTarget As Range Dim oILS As InlineShape On Error GoTo Err_Handler 'Assumes logo is in First Page Header (modify if required) Set oHeader = oDoc.Sections(1).Headers(wdHeaderFooterFirstPage) Set oRng = oHeader.Range If oRng.InlineShapes.Count > 0 Then Set oILS = oRng.InlineShapes(1) Set oRngTarget = oILS.Range oILS.Delete Set oILS = ActiveDocument.InlineShapes.AddPicture(FileName:="C:\New Pic.png", linktofile:=False, Range:=oRngTarget) With oILS 'Do whatever you might need to do. End With End If ChangeLogoPicture = True lbl_Exit: Exit Function Err_Handler: ChangeLogoPicture = False Resume lbl_Exit End Function |
#3
|
|||
|
|||
Headers are not replacing in doc but are in test docss
I have a conundrum, it appears that the headers in the files are not being replaced. However, the test documents i made are.
Any thoughts? |
#4
|
|||
|
|||
Maybe they are not InlineShapes, but Shapes.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Replace or apply new header in multiple files | Carchee | Word VBA | 41 | 01-26-2024 07:27 AM |
Find & Replace in Header/Footer in 1000 files | amodiammmuneerk@glenmarkp | Word | 12 | 03-05-2018 03:31 AM |
Watermark Picture in Header | AK726 | Excel | 2 | 09-17-2014 12:26 PM |
Find & Replace in Header/Footer | PReinie | Word | 6 | 01-22-2014 06:45 PM |
Set Picture Size on Header with VBA | stubdba | Word VBA | 1 | 03-01-2013 05:11 PM |