Userforma Tüm Uzantılarda Resim Çağırma

Katılım
19 Eylül 2012
Mesajlar
292
Excel Vers. ve Dili
2010 türkçe
Merhaba değerli üstatlar.

Aşağıdaki kodlarla Userforma Jpg formatında resim çağırabiliyorum. Çağırılacak resim eğer jpg formatında değil de jpeg formatında yada png formatında ise resmi yine de çağırmak için kodda nasıl bir değişiklik yapmalıyım. Yani "RESİM" adlı klasördeki "CİVATA" adlı resim jpg, jpeg, png yada gif uzantılı olsa bile yine de çağırılsın.

Private Sub TextBox1_Change()
On Error Resume Next
ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".Jpg"
If Dir(ResimDosya) = "" Then
Image1.Visible = False
Else
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".Jpg")
End If
End Sub
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
42,160
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Deneyiniz.

C++:
Private Sub TextBox1_Change()
On Error Resume Next
ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".*"
If Dir(ResimDosya) = "" Then
Image1.Visible = False
Else
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & ResimDosya)
End If
End Sub
 

kulomer46

Altın Üye
Katılım
23 Mart 2007
Mesajlar
1,513
Excel Vers. ve Dili
Microsoft Office LTSC Professional Plus 2021 - Türkçe
Altın Üyelik Bitiş Tarihi
08-06-2027
Merhaba

Alternatif Çalışma

Private Sub TextBox1_Change()

On Error Resume Next

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpg"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpg")
exit sub
end if

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpeg"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpeg")
exit sub
end if

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".png"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".png")
exit sub
end if


ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".gif"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".gif")
exit sub
end if

Image1.Visible = False

End Sub
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,786
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
png uzantılı dosyalar userformda image nesnesinde görüntülenemez.
bunun için dosyada dönüşüm yapmak gerekir
 
Katılım
19 Eylül 2012
Mesajlar
292
Excel Vers. ve Dili
2010 türkçe
Deneyiniz.

C++:
Private Sub TextBox1_Change()
On Error Resume Next
ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".*"
If Dir(ResimDosya) = "" Then
Image1.Visible = False
Else
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & ResimDosya)
End If
End Sub
çok teşekkür ederim.
 
Katılım
19 Eylül 2012
Mesajlar
292
Excel Vers. ve Dili
2010 türkçe
Merhaba

Alternatif Çalışma

Private Sub TextBox1_Change()

On Error Resume Next

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpg"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpg")
exit sub
end if

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpeg"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".jpeg")
exit sub
end if

ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".png"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".png")
exit sub
end if


ResimDosya = ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".gif"
If Dir(ResimDosya) <> "" Then
Image1.Visible = True
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\RESİM\" & TextBox1 & ".gif")
exit sub
end if

Image1.Visible = False

End Sub
çok teşekkür ederim.
 
Üst