Picture in footer through VBA

Grompey

New Member
Joined
Jul 19, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello All!

First time posting since I have a string of code that doesn't seem to work and I can't find the reason why.
The code is used to add and format a picture to the footer of all sheets within a workbook. The code is as follows:

VBA Code:
Private Sub Workbook_Open()
    Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Sheets
        With sh.PageSetup
            .DifferentFirstPageHeaderFooter = False
            .LeftFooterPicture.Filename = "C:\***.jpg"
            With .LeftFooterPicture
                .Height = 19.5
                .Width = 54
            End With
            '.LeftHeader = ("")
            '.CenterHeader = ("")
            '.RightHeader = ("")
            '.LeftFooter = ("")
            .CenterFooter = ("&""Tahoma""&10[[[docname]]]")
            .RightFooter = ("&""Tahoma""&10Page &P of &N ")
            .LeftMargin = Application.CentimetersToPoints(1.5)
            .RightMargin = Application.CentimetersToPoints(0.5)
            .TopMargin = Application.CentimetersToPoints(1.2)
            .BottomMargin = Application.CentimetersToPoints(1.6)
            .HeaderMargin = Application.CentimetersToPoints(0.4)
            .FooterMargin = Application.CentimetersToPoints(0.8)
        End With
    Next sh
End Sub

However when I enter this code only the document name and page numbering is placed correctly the picture does not show up. The picture is only needed when printing the file.
I hope one of you guys could maybe help me on my way.

Kind Regards,

Grompey
 
Last edited by a moderator:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You haven't supplied the LeftFooter string and specified the "&G" format code to insert an image:
VBA Code:
            .LeftFooter = "&G"
            .LeftFooterPicture.Filename = "C:\path\to\image.jpg"
 
Upvote 0
You haven't supplied the LeftFooter string and specified the "&G" format code to insert an image:
VBA Code:
            .LeftFooter = "&G"
            .LeftFooterPicture.Filename = "C:\path\to\image.jpg"
Thanks for the quick response, I will try it later today when I can work on it again!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top