View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Anony Anony is offline
external usenet poster
 
Posts: 35
Default Call user form from ThisWorkbook; close file if form closed

PART 1.
Here are some examples:

In ThisWorkbook:
Private Sub Workbook_Open()
UserForm1.Show 'Or whatever your userform is named
End Sub

---------------------------
In form module:
Private Sub UserForm_Initialize()
Call Main 'This would be the module with your code in it
End Sub


PART 2.
Copy and paste this into the form module:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.Close (True) 'This saves all changes and closes the workbook
End Sub