Results 1 to 4 of 4

Thread: Excel - Modal forms

  1. #1

    Thread Starter
    Addicted Member Lee_S's Avatar
    Join Date
    Dec 2000
    Location
    New Zealand
    Posts
    250

    Excel - Modal forms

    Hi,

    Is it possible to load a form in excel as Modal, but have the assigned macro continue to run in the background?

    I have a command button on a worksheet that starts a macro and opens a userform. I want the userform to show the progress of the macro in a textbox, and when done enable a button on the form. But i dont want the user to be able to move around the workbook whilst its running.

    cheers
    Lee Saunders
    Win XP Professional : VB6 Enterprise / VB 2005 Express

    History admires the wise, but it elevates the brave.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Excel - Modal forms

    Should be possible... in theory at least.
    Code:
    Userform.show vbmodal
    I think. Try that and see whether the code stops until the form is closed.

    Alternatively there are two properties of excel, um updatewindow and supresserrors (or view errors or something) which stop the reporting and updating (scrolling in the background...)

    If you disable the update, but force a refresh on the form it might update...

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Excel - Modal forms

    Have you considered using the StatusBar to show the progress and only show the form when the macro has completed?

    VB Code:
    1. Sub SampleStatusUpdate()
    2. Dim MyStep As Integer
    3. Dim AllSteps As Integer
    4. Dim OldStatusBar As Boolean
    5.  
    6. OldStatusBar = Application.DisplayStatusBar
    7. Application.DisplayStatusBar = True
    8.  
    9. AllSteps = 10
    10. For MyStep = 1 To AllSteps
    11.     Application.StatusBar = "On step " & CStr(MyStep) & " of " & CStr(AllSteps) & "..."
    12.     MsgBox "Hi"
    13. Next MyStep
    14.  
    15. Application.StatusBar = False
    16. Application.DisplayStatusBar = OldStatusBar
    17.  
    18. End Sub
    Last edited by DKenny; Sep 19th, 2005 at 10:45 AM.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel - Modal forms

    Or you can look at it from the other end. Have the button show the form modal but inside the form have the macro code. This will keep the user from doing anything else and yet let the macro code run in the context of the form.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width