Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 11-12-2018, 08:32 PM
Guessed's Avatar
Guessed Guessed is offline Add, Resize & Relocate Header & Footer with Macros Windows 10 Add, Resize & Relocate Header & Footer with Macros Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,184
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You can't wrap text around an inline shape - it needs to be a floating shape. So you need to convert it to a shape if you want the text wrap setting. Shapes are not bothered with paragraph alignment so that probably won't be needed unless you are also putting text in the header.
Code:
Sub AddImageToHeader()
  Dim SrcePath As String, headerPic As InlineShape, aShp As Shape
  SrcePath = "S:\DocBase\Document Templates\Macros\New Macros Nov 2018\Letterhead.jpg"
  Set headerPic = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.AddPicture(SrcePath)
  Set aShp = headerPic.ConvertToShape
  With aShp
    .LockAspectRatio = msoTrue
    .Width = CentimetersToPoints(21)
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
    .Top = 0
    .Left = 0
    .WrapFormat.Type = wdWrapBehind
  End With
End Sub
Also, you can't use ThisDocument because it refers to the document where the macro resides (ie the template) rather than the document you thought you were running the macro on. While you are doing testing in the template you won't notice any problems but you won't get the result you are looking for once you try to run the macro on a document rather than the template.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header and Footer Diablodvs7 Word 1 07-28-2015 07:54 PM
Header and footer aligned in the footer area ashiqghfr Word 2 07-23-2015 01:14 AM
Add, Resize & Relocate Header & Footer with Macros header footer Pierre-Hugues Word VBA 1 08-30-2013 06:06 AM
How to resize the image in the header so that it fits the page Isadora Excel 1 08-20-2013 06:02 AM
Relocate footnotes to facing page Wydeye Word 0 02-23-2010 05:48 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:04 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