PDA

View Full Version : [SOLVED] need explanation of coding frames in vba



GregJG
07-01-2004, 12:45 PM
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?

Tommy
07-01-2004, 01:12 PM
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