How to extract picture from sheet headers?

PATSYS

Well-known Member
Joined
Mar 12, 2006
Messages
1,750
Hi all,

I have a sheet wherein somebody had inserted picture as Header in the PAGE SETUP, HEADER/FOOTER.

When I click on custom header, it only says &[Picture]

Is there a way to extract this image header?

I believe this picture is embedded somewhere in the file because the file size is unusually big. So if it is in the file, there must be a possiblity to extract it.

Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Like this. Not sure if you can do anything with 'pic' though.
Code:
Sub test()
    Dim pic As Graphic
    
    Set pic = ActiveSheet.PageSetup.LeftHeaderPicture
    Set pic = ActiveSheet.PageSetup.CenterHeaderPicture
    Debug.Print pic.Filename
    Set pic = ActiveSheet.PageSetup.RightHeaderPicture
End Sub
 
Upvote 0
John,

Is there a way to also "get the filename extension"? "jpg", for example????
 
Upvote 0
I noticed too that .Filename is just the filename without the extenstion. It looks like Excel just stores the filename as a nicety, because once the graphic is embedded in the .xls file it doesn't matter where it came from or its file type.
 
Upvote 0
interesting code.

i have a code where my some data of my excel is exported in word through VBA CreateObject("Word.Application").

i was wondering how modify the below code where it exports the embedded picture in my excel header to the word header.

any help is appreciated.


Like this. Not sure if you can do anything with 'pic' though.
Code:
Sub test()
    Dim pic As Graphic
    
    Set pic = ActiveSheet.PageSetup.LeftHeaderPicture
    Set pic = ActiveSheet.PageSetup.CenterHeaderPicture
    Debug.Print pic.Filename
    Set pic = ActiveSheet.PageSetup.RightHeaderPicture
End Sub
 
Upvote 0
Has this ever been answered ?

I was thinking programmatically decompressing a copy of the workbook and extracting the image from the xl>media folder which in theory should work albeit being a very ugly hack.

Any better ideas ?
 
Upvote 0
Hi Jaafar,

I haven't looked any further into this. The header/footer picture is a Graphic object type, so maybe there is a way to get to its related/underlying image.
 
Upvote 0
I haven't looked any further into this. The header/footer picture is a Graphic object type, so maybe there is a way to get to its related/underlying image.
Hi John,

There doesnt seem to be a way of getting a StdPicture from the Graphic object ... The Graphic object is an obscure undocumented object which I can't find anywhere or its equivalent in vb6.

Thanks for your interest.
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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