Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2014, 07:07 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline Replace Header Picture Windows 7 32bit Replace Header Picture Office 2010 32bit
Advanced Beginner
Replace Header Picture
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 09-18-2014, 11:25 AM
gmaxey gmaxey is offline Replace Header Picture Windows 7 32bit Replace Header Picture Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 09-19-2014, 09:48 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline Replace Header Picture Windows 7 32bit Replace Header Picture Office 2010 32bit
Advanced Beginner
Replace Header Picture
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default 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?
Reply With Quote
  #4  
Old 09-19-2014, 09:21 PM
fumei fumei is offline Replace Header Picture Windows 7 64bit Replace Header Picture Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Maybe they are not InlineShapes, but Shapes.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Header Picture Replace or apply new header in multiple files Carchee Word VBA 41 01-26-2024 07:27 AM
Replace Header Picture Find & Replace in Header/Footer in 1000 files amodiammmuneerk@glenmarkp Word 12 03-05-2018 03:31 AM
Replace Header Picture Watermark Picture in Header AK726 Excel 2 09-17-2014 12:26 PM
Replace Header Picture Find & Replace in Header/Footer PReinie Word 6 01-22-2014 06:45 PM
Replace Header Picture Set Picture Size on Header with VBA stubdba Word VBA 1 03-01-2013 05:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:04 PM.


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