Wednesday, 22 June 2011

Hide Excel - When loading Userform

This code will hide the excel workbook when the form load. Copy the below code to Userform module. Write in the Workbook open event.

Private m_lngLeft As Long
Private m_lngTop As Long
Private m_lngWindowState As Long

Private Sub Hide_excel()
    Application.Visible = Not Application.Visible
End Sub

Private Sub UserForm_Initialize()
    Application.WindowState = xlMaximized
    m_lngWindowState = Application.WindowState
End Sub

Private Sub UserForm_Terminate()
    Application.Visible = true
    Application.WindowState = m_lngWindowState
End Sub

1 comment: