Hide workbook code

  • Thread starter Thread starter sunspot27
  • Start date Start date
S

sunspot27

Can someone help?

I have a user form that i created in a spreadsheet to automatically
launch when the workbook is opened. Can anyone tell me what code i can
use to prevent the workbook from being displayed when i open it and
only display the user form? Also where i need to place this.

Also what code can i use to break from a loop or a case or jus end the
code compilation ?

Thanks
 
You can do this:
In the Workbook open event:

Private Sub Workbook_Open()
UserForm1.Show
End Sub
In the userform code:

Private Sub UserForm_Initialize()
Application.WindowState = xlNormal
Application.Left = -2000 'makes excel be off screen
End Sub

Private Sub CommandButton1_Click()
Application.Left = 0 'restores excel
Application.WindowState = xlMaximized
Unload Me
End Sub

To exit from a for/next loop:
Exit For
or
Go to some label after the Next

Don't think you can interrupt code compilation!
Esc key or Ctrl/Break could interrupt a loop as well.

HTH
Bob Umlas
Excel MVP
 
Back
Top