![]() |
#1
|
|||
|
|||
![]()
Hi all
I have been (unsuccessfully) trying to create a macro that will insert a picture into a footer. I record the macro step by step and yet when I run it the picture is just inserted within the document not the footer. I can just have it inserted on normal.dotm as it won't be used for every document. I don't have any understanding of Visual Basic. Help please! Thanks - Sharon P.S. This is what my macro recorded: Sub eletterfooter() ' ' eletterfooter Macro ' ' With Selection.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(1.27) .BottomMargin = CentimetersToPoints(1.27) .LeftMargin = CentimetersToPoints(1.27) .RightMargin = CentimetersToPoints(1.27) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Selection.TypeText Text:="this is the footer" Selection.TypeParagraph Selection.InlineShapes.AddPicture FileName:= _ "C:\Users\sharon\Desktop\case eletter\Footer.jpg", _ LinkToFile:=False, SaveWithDocument:=True Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdWord, Count:=5, Extend:=wdExtend Selection.Delete Unit:=wdCharacter, Count:=1 ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument End Sub |
#2
|
|||
|
|||
![]()
Hi Sharon
I found this piece of code on the web and have tested it and it seems to work okay for me. You will need to change the filename/path to match your own picture. Credit for this code goes to someone called Shasur on p2pwrox.com. Good luck. Tony Sub Word_Insert_Image_in_Header() Dim oWD As Word.Document Set oWD = ActiveDocument With oWD.Sections(1) .Footers(wdHeaderFooterPrimary).Range.InlineShapes .AddPicture FileName:="C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg", _ LinkToFile:=False, SaveWithDocument:=True End With End Sub |
#3
|
|||
|
|||
![]()
Hi Tony
Thanks for getting back to me. I have copied that, pasted it into my macros and changed the file name. It shows up in my listed macros, but then when I run it (assigned it a button) I just seem to get errors. Shar |
#4
|
|||
|
|||
![]() Quote:
Are you able to post a copy of your document and I will take a look in the morning. Tony |
#5
|
|||
|
|||
![]()
I have just been trying it on a new blank document. Once I got it working on that I was going to try on the letters.
|
#6
|
|||
|
|||
![]()
Hi Sharon
If you get it working in a blank document then the only issue you may need more help on is where you want the picture inserted in the footer if you have other text already in the footer. Good luck. Tony |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
rowan.bradley | Drawing and Graphics | 6 | 05-18-2013 05:26 PM |
![]() |
gary1 | Word | 9 | 12-16-2012 04:37 PM |
![]() |
Jennifer Murphy | Drawing and Graphics | 3 | 10-09-2012 05:12 AM |
![]() |
rfhall50 | Word VBA | 2 | 10-25-2010 12:41 PM |
![]() |
alexcalgary | Drawing and Graphics | 2 | 10-16-2010 03:29 PM |