Results 1 to 6 of 6

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

  1. #1

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



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Super Moderator JoePublic's Avatar
    Join Date
    Sep 2011
    Location
    Askew
    Posts
    170
    Articles
    0
    Which version of Excel, and what is actually happening?

  3. #3
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,021
    Articles
    79
    Blog Entries
    14
    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?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  4. #4
    Super Moderator JoePublic's Avatar
    Join Date
    Sep 2011
    Location
    Askew
    Posts
    170
    Articles
    0
    If using 2010, do not turn off printcommunication

  5. #5
    Super Moderator JoePublic's Avatar
    Join Date
    Sep 2011
    Location
    Askew
    Posts
    170
    Articles
    0
    The &G is needed to actually show the picture.

  6. #6
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,021
    Articles
    79
    Blog Entries
    14
    Quote Originally Posted by JoePublic View Post
    The &G is needed to actually show the picture.
    Ah, didn't realize that. (I've don't know that I've ever actually put a picture in the header of an Excel document!)
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •