+ Reply to Thread
Results 1 to 12 of 12

How do I Resize image with userform

  1. #1
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    How do I Resize image with userform

    I have a userform that I am using as a splash screen while the spreadsheet loads and does some initial processing


    So the userform is called Splashscreen
    The userform has an image which exactly fills the userform. The userform properties for the image are
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    The userform resizes correctly but the image does not resize at all.
    It makes no difference if I set .fmPictureSizeMode is set to 3(fmPictureSizeModeZoom)

    I can set the zoom and that does make the image change size but both dimensions change the same amount
    However the client monitor can be square, wide or almost any other shape si some of the splashscreen image will be lost.
    Is there any way I can stretch the image to follow the userform? (recognising that the image will be distorted if the aspect ratio is changed)

    TFAI
    Last edited by RincewindWIZZ; 02-25-2015 at 07:34 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I Resize image with userform

    Can you post example file so we can see exactly what is happening. Only need to see the splash screen userform.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Well I finally found a workaround.
    It seems that the stretching of the picture only applies when the picture is loaded into the form. Now this may be because I have some other property set about which I know nothing (and I'd be very grateful is someone would tell me)

    However, this achieves what I want
    1. Save the picture as a file (jpg) in the application directory
    2. set the PictureSizeMode of the form to 1 (Stretch)
    3. In the form Initiallise routine
    set the desired size of the form. I was using:
    SplashScreen.Height = Application.UsableHeight
    SplashScreen.Width = Application.UsableWidth
    4 Load the picture from the file
    Me.Picture = LoadPicture("FullPathandFileName.jpg")
    5 Show the form
    I actually unloaded the form at the end of my spreadsheet initialisation process.

    BUT I CONSIDER THIS A WORKAROUND
    Surely it is possible to get the form to resize the image when the userform itself is resized?
    Please? Someone?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I Resize image with userform

    code in userform. Will display the copy icon filling the userform. Double click userform to reduce size along with stretched image

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Thanks for your interest

    Attached is the Userform.

    In the Auto-Open routine, I will typically set the height and width to the application.Usableheight and width and then show the form.
    (The idea being to give the user something to look at while the spreadsheet is loading and doing initial processing. I Unload the userform at the end of this initialisation process.)

    When I do this, the form is expanded to the dimensions I set but the picture remains the same size. The Additional area is filled with, I presume, the form background colour.

    The workaround that I describe results in the picture filling the form correctly (and according to the applications aspect ratio) But it is irritating to have to have the picture as a separate file (and slower - the form completes and show after around 2 seconds and the initialisation process finishes about 1 second later).

    All suggestions welcome.

    As a PS -This does not work well in real life. If I step through in the debugger everything is great. if I simply load the workbook, the userfornm outline shows with no picture for 2 of the 3 seconds it takes to load the workbook.
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Well b*g*e* me. That works just fine.

    But I have previously tried that because the code is still in the userform initialisation routine but commented out.
    Oh well I'm not going to waste time figuring out why.

    Thanks

  7. #7
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Whooops = spoke prematurely
    Seems the picture in the userform never gets displayed. (Excel 2007/2013)

    The code is
    Auto_Open immediately shows the form
    The form initialisation immediately sets height, width and top left position (and does nothing else)
    Auto_Open then issues userform.show
    Spreadsheet initialisation calculations take place
    Auto_open then unloads the form

    What actually happens is
    1. Everything stays blank for about 1 sec
    2. the frames of the two windows in the workbook are displayed (and bizzrely the contents of 1 cell in one of them) for about 1/2 sec
    3 The two workbook windows complete with all data are displayed for maybe 1/10th second
    3. Then the blank userform is displayed while initialisation completes
    5. then the userform is unloaded and the workbook appears in all its glory.

    So
    Why does the picture in the userform not display - it works fine when I step through in debug mode and the userform plus picture displays on the userform.show statement.

    It also seems that the standard excel process of loading the spreadsheet is going on in parallel and finishes before the Auto_Open statement executes so the existing windows of the workbook will display before the splashscreen is loaded.

    So maybe there is a better way of setting up a splashscreen while excel is loading workbooks?

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I Resize image with userform

    I can't do anything with a picture.

    Try adding a doevents and or repaint command to the code.

  9. #9
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Sorry about the frm. Bit of a novice at this stuff.

    Will try a Repaint etc and report back. But still concerned about Excel loading workbook first and showing splash screen second. Seems the wring way round :-(

    Thanks again for your help
    Attached Files Attached Files

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I Resize image with userform

    Is the splashscreen user form in the workbook being opened? (I can't tell from the files attached as there are just the frm and frx files).
    Where is the code for showing the userform, Workbook_Open event maybe?

  11. #11
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    As in earlier post:
    Auto_Open routine - Automatically run on open the workbook) has splashscreen.show as 1st executable line
    SplashScreen initialisation has only 3 lines which set height, width and top left position (and does nothing else)
    Auto_Open then does spreadsheet initialisation calculations
    Auto_open then unloads the form

  12. #12
    Registered User
    Join Date
    03-03-2005
    Posts
    41

    Re: How do I Resize image with userform

    Repaint and Doevents did nothing
    Repait after teh .show produced an error (writing to read onkly attribute)
    do events did nothing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how do I scale/resize an image with VBA
    By bsapaka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2014, 07:14 PM
  2. resize image with vba
    By 13lack13lade in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2013, 08:59 PM
  3. [SOLVED] How do I resize an inserted image in a cell?
    By tigerbenn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 10:55 AM
  4. Image file resize
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2009, 05:01 AM
  5. resize userform image to fit on any monitor
    By timspier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2006, 01:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1