ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Picture in UserForm (https://www.excelbanter.com/excel-programming/421516-picture-userform.html)

Howard31

Picture in UserForm
 
Hi All,

I'm having trouble getting a picture into a picture control in a userform.
Every time I select a picture file for the control I get a error message,
something like 'Picture file is not valid'

--
A. Ch. Eirinberg

Chip Pearson

Picture in UserForm
 
What picture format are you using? I don't think that you can use PNG
files. GIF and JPG work fine. E.g.,

Drag an Image control on to your form and then use code like

Private Sub CommandButton1_Click()
Dim FileName As String
Dim Pict As stdole.StdPicture
FileName = "C:\CPearsonWeb\Images\alerter1.jpg"
Set Pict = New stdole.StdPicture
Set Pict = LoadPicture(FileName)
UserForm1.Image1.Picture = Pict
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 18 Dec 2008 16:34:00 -0800, Howard31
wrote:

Hi All,

I'm having trouble getting a picture into a picture control in a userform.
Every time I select a picture file for the control I get a error message,
something like 'Picture file is not valid'


Howard31

Picture in UserForm
 
Thanks a million Chip, The picture I was trying to load was in fact PNG, I've
converted it to JPG and it loaded!
--
A. Ch. Eirinberg


"Chip Pearson" wrote:

What picture format are you using? I don't think that you can use PNG
files. GIF and JPG work fine. E.g.,

Drag an Image control on to your form and then use code like

Private Sub CommandButton1_Click()
Dim FileName As String
Dim Pict As stdole.StdPicture
FileName = "C:\CPearsonWeb\Images\alerter1.jpg"
Set Pict = New stdole.StdPicture
Set Pict = LoadPicture(FileName)
UserForm1.Image1.Picture = Pict
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 18 Dec 2008 16:34:00 -0800, Howard31
wrote:

Hi All,

I'm having trouble getting a picture into a picture control in a userform.
Every time I select a picture file for the control I get a error message,
something like 'Picture file is not valid'




All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com