Can we scroll through images and change the aspect ratio in a UserForm?

USAMax

Well-known Member
Joined
May 31, 2006
Messages
849
Office Version
  1. 365
Platform
  1. Windows
I need to be able to select between windows used in home remolding. I have several GIF images that I would like to scroll through and I want to use their file names in the bill of material.

I also want to know if there is a way to change the aspect ratio based on the window's dimensions.


My thanks to my Mr Excel family.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Here is an example:

Code:
' user form module
Dim i%
Private Sub UserForm_Initialize()
i = 0
End Sub


Private Sub CommandButton1_Click()              ' click to change picture
Dim a, asp
a = Array("joke.gif", "charts.gif")
asp = Array(2, 3)                               ' aspect ratios
If i > UBound(a) Then i = 0
With Me.Image1
    .Picture = LoadPicture("c:\pub\" & a(i))    ' your directory here
    .Width = 50
    .Height = 50 * CDbl(asp(i))
    .PictureSizeMode = fmPictureSizeModeStretch
End With
Me.Repaint
Me.TextBox1 = "c:\pub\" & a(i)                  ' file name
i = i + 1
End Sub
 
Upvote 0
Worf, thank you so much for responding to my question and I am sorry have not seen it until now. It looks like it will work so I will test it out this weekend.

Thank you again!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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