ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check image availability on userform (https://www.excelbanter.com/excel-programming/304690-check-image-availability-userform.html)

gki

Check image availability on userform
 
Hello all,

Is there anyone who knows how to check the availability of image in th
folder?

I need it on my userform, if there is no image belonging to the cod
that it is requested then it should give me the message of "No imag
available".

But when I change the code, the image should be visible.

Please have a look at my code below,

With Image1
.Picture=LoadPicture(PathName)
If Image1.Picture=vbNull Then Image1.Visible=False An
lblnoimage.visible=True

End With


Just for your imformation; lblnoimage="No Image available"
At first, the code numbers of images were Numeric, then I add a lette
at the end of each code, like before 45120 after 45120a.

I thought this would solve the problem. But I cannot make the
image go away once I entered the wrong code or the code which has n
image in the database...

Please help me out,

:confused:


Thank yo

--
Message posted from http://www.ExcelForum.com


Robin Hammond[_2_]

Check image availability on userform
 
Something like this

Private Sub CommandButton1_Click()
Dim strPath As String
'presumably some code here to pick the path
strPath = "D:\Documents and Settings\UserName\My Documents\My
Pictures\Pic1.jpg"
If Dir(strPath) = "" Then
Image1.Picture = Nothing
lblNoImage.Visible = True
Else
Image1.Picture = LoadPicture(strPath)
lblNoImage.Visible = False
End If
End Sub

Robin Hammond
www.enhanceddatasystems.com

"gki " wrote in message
...
Hello all,

Is there anyone who knows how to check the availability of image in the
folder?

I need it on my userform, if there is no image belonging to the code
that it is requested then it should give me the message of "No image
available".

But when I change the code, the image should be visible.

Please have a look at my code below,

With Image1
Picture=LoadPicture(PathName)
If Image1.Picture=vbNull Then Image1.Visible=False And
lblnoimage.visible=True

End With


Just for your imformation; lblnoimage="No Image available"
At first, the code numbers of images were Numeric, then I add a letter
at the end of each code, like before 45120 after 45120a.

I thought this would solve the problem. But I cannot make the
image go away once I entered the wrong code or the code which has no
image in the database...

Please help me out,

:confused:


Thank you


---
Message posted from http://www.ExcelForum.com/




gki[_2_]

Check image availability on userform
 
Hey Robin,

Thank you very for your help.... It works very good now...

There is another question I would like to ask;


I also would like transfer the information I see on my userform to th
worksheet once you click the Print Preview button;

But I could not make it that the image goes onto worksheet and become
smaller;

The code is shown as below;

Private Sub cmdprintd_Click()
Static comp as Object
Application.ScreenUpdating=False
Dim px As Picture
For Each px in Sheets("Sheet1").Pictures
px.Delete
Next px
Set comp=Activesheet.Pictures.Insert(Dir:=strPath)
comp.Top=108
comp.Left=425
Application.ScreenUpdating=True

Sheets("Sheet1").Range("A1").Value=txtcode.value

Me.Hide
Sheets("Sheet1").PrintPreview
Me.Show

End Sub


I get an error at "Set comp=Activesheet.Pictures........."

I cannot see it why it doesnt work

:confused

--
Message posted from http://www.ExcelForum.com


gki[_3_]

Check image availability on userform
 
I made it work... Thanks for help..

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:57 PM.

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