+ Reply to Thread
Results 1 to 10 of 10

Modeless UserForm problem

  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2007
    Posts
    15

    Thumbs up Modeless UserForm problem

    Hi,

    I have a little problem.

    On opening of my WorkBook I refresh my PivotTable and that takes a while so while its refreshing. So I want to launch a UserForm that basically have a loop showing progress bar similar than the Windows loading bar (i.e. a set of green vertical green bars moving in a black rectangle).

    Her is the code in THisWorkbook :

    Please Login or Register  to view this content.
    ...and here is the code in my UserForm :

    Please Login or Register  to view this content.
    I don't know what code to put where (UserForm, Workbook, etc..)
    Can someone help me on this issue please.

    Thank you for your help
    Jean
    Last edited by jdelorme; 07-14-2009 at 02:28 PM. Reason: Clarification

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modeless UserForm problem

    Why is the Pivottable taking so long to refresh?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-04-2009
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Modeless UserForm problem

    I have no problems with the time it takes. But if you want to know I get the data from MS Project Server and the data connection takes a little longer than if it was local.
    That's all

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

    Re: Modeless UserForm problem

    The problem you will have is that excel does the refresh before moving on to the next VBA command so the userform/progress bar will only be updatable once the refresh is complete, which obviously defeats the point of the progress bar.

    The only thing you can do is the animated gif in a usreform, which should run whilst the refresh is going on. Although it will take longer to refresh as it's doing 2 things now.

    So load userform, start animation of gif, refresh table, close userform.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    06-04-2009
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2007
    Posts
    15

    Question Re: Modeless UserForm problem

    Thanks Andy Pope,

    That's exactly what I want to do. And I think that is what I thought my code was doing but ahter loading the userform and display my progress bar (which icindemtlt works perfecly well) it does not not continue on to do the refresh of my Pivot table.

    Thank you

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

    Re: Modeless UserForm problem

    So if you place a Stop command after the Set command it never gets there?

    Please Login or Register  to view this content.
    Is your userform called Userform?

  7. #7
    Registered User
    Join Date
    06-04-2009
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Modeless UserForm problem

    Hi Andy,

    It's exactly right... After my "Set frm = New frmCursor" line it does not continue in this macro.
    My UserForm is called frmCursor.
    I've tried, as suggested in the forum, to move my Userform_Initialize event and it does exactly the same thing.... so I must do something wrong or rather there is something I donnot do.

    Any suggestions ?
    Jean

  8. #8
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Modeless UserForm problem

    Erm, I wouldn't expect it to get to that line following the userform creation...

    As far as I know Excel doesn't run multithreaded, so won't run 2 sets of code at the same time.

    So taking your code...

    Please Login or Register  to view this content.
    Causes this code to run:
    Please Login or Register  to view this content.
    The animation loop will loop indefinitly waiting for 'StopLoop' to be True, but there is nothing to set it to true.

    I know that you have StopLoop=True in your main code, but if Excel doesn't multithread it won't run your main code at the same time as running this userform code.

    I believe when Andy said to use an animated gif, he meant for you to use an animated Gif, not to animate your own graphic.

    I could of course be wrong, but that is what it seems like to me...
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

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

    Thumbs up Re: Modeless UserForm problem

    I assume you have not got Option Explicit set as I would have expected your open event to look more like this.

    Please Login or Register  to view this content.
    As Phil points out all your userform will do is show some animation and THEN refresh the pivot table. Taking longer than before.

    If you really want to display something animated then you need to use an animated gif file displayed in a webbrowser control that is displayed modeless

    Once the refresh command completes unload the userform.

  10. #10
    Registered User
    Join Date
    06-04-2009
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Modeless UserForm problem

    Thanks for all the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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