Results 1 to 4 of 4

Thread: Modal UserForm becomes modeless after SaveAs

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2003
    Location
    USA, East Coast
    Posts
    257

    Modal UserForm becomes modeless after SaveAs

    Hello,

    During system testing of my Excel 97/VBA, I have discovered the following bug:

    I have a modal UserForm which controls the Active Worksheet (which is underneath the UserForm). I click a Save button to copy & save the Active Worksheet into another Workbook.

    Here's the bug: When control returns back to my App, the UserForm is still there but in a modeless state. I can access the Worksheet - scroll, type into cells, etc. This must not happen, the Worksheet must always be controlled through the UserForm.

    How do I set control back to the UserForm and disable direct access to the Worksheet after returning from the SaveAs routine?

    Thank you,
    CyberJar

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You could probably trap for this in the Workbook_Activate() event
    and handel it some way to restore the modality of the userform or
    close it and re-open it.

    HTH
    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

  3. #3
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    Can you post your code, I tried but am unable to duplicate this error. My control stays with the form and does not shift to the sheet. Using XL97.


    btw:
    You might also want to protect your sheet via a password such that if control is passed to the sheet, that the users can't do any damage.
    And where your form modifies the sheet, unlock and lock the sheet for the changes only.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2003
    Location
    USA, East Coast
    Posts
    257
    Hey There,

    Thanks for your replies.

    I was able to solve this by explicitly setting the Worksheet to Activate.

    After Downloading, the last statement was:

    MyWorksheetObject.Activate


    And this did the trick! Focus returns to the controlling UserForm .

    Thank You,
    CJ

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