Share via

Insert picture in headers using VBA

Anonymous
2016-08-19T21:42:50+00:00

I have written a macro that creates a custom header based on information the user enters into my spreadsheet and adds that header to every page of the worksheet.  While I have no trouble getting this to work for text, I can't figure out how to insert a logo.  I understand that I can use &G to add a picture to my header, e.g. :

wsheet.PageSetup.LeftHeader = "&G"

but how do I specify what graphic to use?  I would like to be able to use an image that is stored inside the spreadsheet, to make it "portable".

Please let me know how I can do this -- thanks!

Yours truly,

Hugh John

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-08-22T14:51:29+00:00

    Thanks, Graham!

    HJ

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-08-21T00:34:07+00:00

    Thanks, Graham.

    The key to my question is that I'm trying to use a VBA macro to create the header (and footer) from information entered by the user in pre-defined cells in the worksheet.  So essentially, if I use the following line in my macro:

    wsheet.PageSetup.LeftHeader = "&G"

    how do I specify the image that "&G" refers to?  Do I need to enter the name/location of the image after the "&G" and, if so, what is the syntax I need to use?  If not, what is the process?

    Ideally, I'd like to be able to specify an image that exists inside the spreadsheet, rather than having to choose it from a folder, but I realize this might not be possible, so I'm just hoping to find out what it is possible to do....

    Thanks again for your help!

    Regards,

    Hugh John

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-08-20T05:38:26+00:00

    Was this answer helpful?

    0 comments No comments