ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Footer Picture (https://www.excelbanter.com/excel-programming/345263-footer-picture.html)

Richard

Footer Picture
 
How do I copy the footer/header picture from one worksheet to another?

The following code will put the existing picture into the Graph object but
when I try to set the Graph object of the new workbook I get an error...

Sub CopyFooterPicture()
On Error GoTo Trap
Dim wkOld As Worksheet, wkNew As Worksheet
Dim gphOld As Graphic, gphNew As Graphic

' get existing picture
Set wkOld = ThisWorkbook.Sheets("sheet1")
Set gphOld = wkOld.PageSetup.CenterFooterPicture

' new worksheet and picture
Set wkNew = ThisWorkbook.Worksheets.Add
' display the footer
wkNew.PageSetup.CenterFooter = "&G"
' get the new picture
Set gphNew = wkNew.PageSetup.CenterFooterPicture
' this bombs, since the Old filename is just the filename of the original
picture file w/o the extension
gphNew.Filename = gphOld.Filename

Exit Sub
Trap:
Debug.Print Err.Number & ": " & Err.Description
End Sub

Thanks,

--
Richard


All times are GMT +1. The time now is 07:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com