Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2013, 04:46 AM
Sharon Sharon is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Novice
Macro to insert picture in footer
 
Join Date: Jan 2013
Posts: 3
Sharon is on a distinguished road
Default Macro to insert picture in footer

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
Reply With Quote
  #2  
Old 01-28-2013, 05:34 AM
OTPM OTPM is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 01-28-2013, 06:28 AM
Sharon Sharon is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Novice
Macro to insert picture in footer
 
Join Date: Jan 2013
Posts: 3
Sharon is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 01-28-2013, 01:14 PM
OTPM OTPM is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Quote:
Originally Posted by Sharon View Post
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
Hi Sharon
Are you able to post a copy of your document and I will take a look in the morning.
Tony
Reply With Quote
  #5  
Old 01-29-2013, 01:55 AM
Sharon Sharon is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Novice
Macro to insert picture in footer
 
Join Date: Jan 2013
Posts: 3
Sharon is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 01-29-2013, 03:12 AM
OTPM OTPM is offline Macro to insert picture in footer Windows 7 32bit Macro to insert picture in footer Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to insert picture in footer Insert Picture changes colors rowan.bradley Drawing and Graphics 6 05-18-2013 05:26 PM
Macro to insert picture in footer insert picture file location gary1 Word 9 12-16-2012 04:37 PM
Macro to insert picture in footer Insert picture options, what's the difference? Jennifer Murphy Drawing and Graphics 3 10-09-2012 05:12 AM
Macro to insert picture in footer Macro for Picture Insert rfhall50 Word VBA 2 10-25-2010 12:41 PM
Macro to insert picture in footer Can I insert a picture into a picture ? alexcalgary Drawing and Graphics 2 10-16-2010 03:29 PM

Other Forums: Access Forums

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