Consulting

Results 1 to 2 of 2

Thread: need explanation of coding frames in vba

  1. #1
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    2
    Location

    need explanation of coding frames in vba

    I am trying to understand what exactly Frame_enter() or Frame_exit() is for.

    I thought that frame_enter meant that as soon as you entered into the frame for anything(checkboxes, textboxes, ect.) that your code would be applied. and the same for when you exit the frame for frame_exit()

    example (the code is short, just for this);

    Private Sub Frame1_Enter() 
    Dim wb as workbook 
    set wb = workbooks.open("path") 
    activeworkbook.sheets("name").activate 
    end sub 
    
    Private Sub Frame1_Exit(ByVal Cancel As MSForms.ReturnBoolean) 
    wb.close true 
    end sub
    shouldn't that open and close the workbook?

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    The problem is the way wb is defined. wb should be defined as a global not local.


    Private wb As Workbook
    
    Private Sub Frame1_Enter()
        Set wb = Workbooks.Open("path")
        ActiveWorkbook.Sheets("name").Activate
    End Sub
    
    Private Sub Frame1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        wb.Close True
    End Sub

Posting Permissions

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