Consulting

Results 1 to 4 of 4

Thread: Solved: Loading and unloading forms

  1. #1
    VBAX Regular
    Joined
    Sep 2011
    Posts
    78
    Location

    Solved: Loading and unloading forms



    Where is the best place to put a "Load Form"? The app's "Auto_Open" event?

    And "Unload Form"? In the app's "Auto_Close" or somewhere else?

    Does a form automaticaly unload when Excel is closed?

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Whenever you need it.

    in Excel e.g.

    [VBA]
    Private Sub Workbook_open()
    userform1.show
    end sub
    [/VBA]

    and
    Whenever you don't need the userform anymore

    [VBA]
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    unload Userform1
    End Sub

    [/VBA]

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Since Load UserForm allocates memory to hold it, I only Load a UF when I will need it, and Unload it when I'm through with it.

    Excel's garbage collection is pretty good, so when Excel closes, all the allocated memory is released

    Paul

  4. #4
    VBAX Regular
    Joined
    Sep 2011
    Posts
    78
    Location
    Thanks for both replies. I understand.

Posting Permissions

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