Inserting a picture in the right and another in the left side of the header

AndreasL

New member
Joined
Oct 12, 2011
Messages
4
Reaction score
0
Points
0
Hi,

I want to take a .jpg picture from my computer and insert it in the left and another one in the richt corner of the header. In my opinion this program should work but it won't and I don't know why.

Here is my code I have until now:
Code:
With ActiveSheet.PageSetup.LeftHeaderPicture
            .Filename = "D:\Eigene Dateien\Customer Logo.jpg"
End With
        
 With ActiveSheet.PageSetup.RightHeaderPicture
            .Filename = "D:\Eigene Dateien\picutre2.jpg"
End With
                
'Insert of the Header and Footer including pictures
With ws.PageSetup
                .LeftHeader = "&G"
                .CenterHeader = "Electrical Load Analysis"
                .RightHeader = "&G"
                .CenterFooter = "&A"
                .RightFooter = Format(Date, "dd.mm.yyyy")
End With

Thank you for your help
 

JoePublic

Super Moderator
Staff member
Joined
Sep 16, 2011
Messages
233
Reaction score
3
Points
18
Location
UK
Excel Version(s)
2016
Which version of Excel, and what is actually happening?
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,524
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
First thing I see is that the first two With constructs refer to the ActiveSheet, while the third refers to ws. Those may not be the same worksheets.

I'd write it as follows:
Code:
    With ws.PageSetup
        .LeftHeaderPicture.Filename = "D:\Eigene Dateien\Customer Logo.jpg"
        .RightHeaderPicture.Filename = "D:\Eigene Dateien\picutre2.jpg"
        .LeftHeader = "&G"
        .CenterHeader = "Electrical Load Analysis"
        .RightHeader = "&G"
        .CenterFooter = "&A"
        .RightFooter = Format(Date, "dd.mm.yyyy")
    End With

Curious though... what is the "&G" for?
 

JoePublic

Super Moderator
Staff member
Joined
Sep 16, 2011
Messages
233
Reaction score
3
Points
18
Location
UK
Excel Version(s)
2016
If using 2010, do not turn off printcommunication
 

JoePublic

Super Moderator
Staff member
Joined
Sep 16, 2011
Messages
233
Reaction score
3
Points
18
Location
UK
Excel Version(s)
2016
The &G is needed to actually show the picture.
 
Top