1 Attachment(s)
Resize Image Control at runtime
I am stuck in a very peculiar situation. Seems like no one has ever asked this question before or maybe I am not able to search for it.
There is a Userform in Excel. It has an Image Control. It's PitcutreSizeMode = fmPictureSizeModeClip. I know I can change the PitcutreSizeMode to Zoom or Stretch but I do not want to do that. What I want is at runtime, the size of the control should resize to match the image's size. The image is already embeded inside the Image control. I do not want to use the relative path of the image.
Let's say we have the following measurements when the userform is initialized
Image1.Height: 54
Image1.Width: 84
Image1.Picture.Width: 5821
Image1.Picture.Height: 3874
This is what I am trying to achieve.
Attachment 170617
Any idea on how do I proceed with this?
Re: Resize Image Control at runtime
Can you change the size mode to Auto?
Edit: I guess not...
But you can set Autosize to True.:)
Re: Resize Image Control at runtime
Autosize = True will not help. It is already set to Autosize = True at design time. I then resize the control and make it very small. I want to resize it at runtime.
Re: Resize Image Control at runtime
Ok you gave me an idea. It does solve the problem and for that due credit to you (rated your answer)
I set the Autosize = False and then set it to true in UserForm_Initialize()
Code:
Private Sub UserForm_Initialize()
imgMain.AutoSize = True
Me.Width = imgMain.Width + 10
Me.Height = imgMain.Height + 10
End Sub
I am also interested to see a solution which involves pixel/point handling as per a user's system config (DPI).