Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a picture in excel header to show on forms image control

Status
Not open for further replies.

claudehenri

Technical User
May 31, 2003
48
0
0
AU
Hi All

I don't know if its possible, but what I would like to do is take the inserted header picture and show it in a Image control on a form. don't really know where to start.

Claude-Henri
 
How about something like:
Code:
Image1.Picture = LoadPicture(Sheet1.PageSetup.LeftHeaderPicture.Filename)
You can substitute
Code:
LeftHeaderPicture.Filename
with
Code:
RightHeaderPicture.Filename
or
Code:
CenterHeaderPicture.Filename
depending on where the image in the header is located. The above code assumes that the header is on Sheet1.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Thanks Harleyquinn

O.K. this works if I have just inserted this picture into the header, during the session with the file. If i then save and close the file with the header, re-open and try to run this code I get

Run-time error '53':
File not found

any further suggestions? My code is as below

Private Sub UserForm_Initialize()

With ThisWorkbook.Worksheets("DATA")
Image1.Picture = LoadPicture(.PageSetup.LeftHeaderPicture.Filename)
End With

End Sub

C-H.
 
Ah, this is because Excel only stores the actual name of the file in LeftHeaderPicture.Filename (no path or extention).
It might not be the best, most elegant or most robust solution but if all of your pictures are in the same folder and have the same extention you could try something like this as a workaround...
Code:
Private Sub UserForm_Initialize()

With ThisWorkbook.Worksheets("DATA")
  Image1.Picture = LoadPicture("C:\" & .PageSetup.LeftHeaderPicture.Filename & ".bmp")
End With

End Sub
Don't know if it will work for you but it's worth suggesting.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
If you aren't changing the Header picture and the images picture is set during the setting and saved, next time you open the form it should appear as saved. Just take the code off the form initialize and try it like that.

Cheers

Harleyquinn

---------------------------------
For tsunami relief donations
 
Sorry Harleyquinn
Another case of not fully explaning myself.

What I'm doing is setting up a form that lets you change all the headers and footers on all the sheets. Image1 is the image which is already in the header. I would like the user to see the current image in the header (even if the file has been closed).

If its not possible well I'll just have to do without, but i'd like to if i could.

Claude-Henri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top