Multiple Image Format On UserForm

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello All,
Code:
Me.Image1.Picture = LoadPicture(fPath & "/" & Me.ListBox1.Column (0 , i) & ".jpg")

How do I get other formats to work in addition to the jpg files?
Thanks
Kelly
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Oh okay. I have looked at the article. Thanks. But I don't know how to code multiple formats. So that if any of those files is found it will show on the control.
Thanks
 
Upvote 0
Code:
Me.Image1.Picture = LoadPicture(fPath & "/" & Me.ListBox1.Column (0 , i) & ".jpg"

I mean how do I add multiple formats. Gif, .bmp, .jpg etc. What I have here can take only one format.
Thanks
Kelly
 
Upvote 0
Assuming you would only have image files with those names, you could use Dir:

Code:
Dim sFile as string
sfile = Dir(fPath & "/" & Me.ListBox1.Column (0 , i) & ".*"
if sfile <> vbnullstring then Me.Image1.Picture = LoadPicture(fPath & "/" & sfile)
 
Upvote 0
Assuming you would only have image files with those names, you could use Dir:

Code:
Dim sFile as string
sfile = Dir(fPath & "/" & Me.ListBox1.Column (0 , i) & ".*"
if sfile <> vbnullstring then Me.Image1.Picture = LoadPicture(fPath & "/" & sfile)

Yes this worked just perfect!!!!
Thanks
Kelly
 
Upvote 0

Forum statistics

Threads
1,216,878
Messages
6,133,205
Members
449,788
Latest member
sutthipv

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