Scenario
I have a userform whereby excel workbook will be hidden while opening using the following method of Application.Visible = False. These are the codes
My userform
show excel button is Commandbutton1hide excel button is Commandbutton2
This workbook
Codes
Private Sub Workbook_Open()
Call hideExcel
UserForm1.Show
End Sub
Userform1
Codes
Private Sub CommandButton1_Click()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = True
Else
Application.Visible = True
End If
End Sub
Private Sub CommandButton2_Click()
Call hideExcel
End Sub
Sub UserForm_Initialize()
Call hideExcel
End Sub
Private Sub UserForm_Terminate()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = True
Else
Application.Visible = True
End If
End Sub
Sub userform_click()
Call hideExcel
End Sub
Module
Codes
Sub hideExcel()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = False
Else
Application.Visible = False
End If
End Sub
Problem
The problem I am facing is
- Open my macro and userform activated. Lets call this file
A - Then open another workbook. Lets call this file
B - Tried to close file
Bwhile workbookAis hidden. But there is a prompt to close fileAalso and eventually all excel will be closing including my macro file which isA.
Does anyone know what is the problem here?



