I have a userform which is created in vba and I want to display only the userform when I open my excel... is there a way to do this.. I have already tried the codes such as
application.visible = false , activewindow.visible= false
if I use this codes in the module before open the files which are already open will b hidden along with the file which I am opening can someone tel me how can i particularly hide the file which I want to open and display the userform
Try something like this
1- Create a user form with 2 button (see below pic)
2- ThisWorkbook code
Private Sub Workbook_Open()
UserForm1.Show vbModeless
End Sub
3- Form code
Private Sub CommandButton1_Click()
If Workbooks.Count > 1 Then
Windows("Test.xlsm").Visible = True
Else
Application.Visible = True
End If
End Sub
Private Sub CommandButton2_Click()
If Workbooks.Count > 1 Then
Windows("Test.xlsm").Visible = False
Else
Application.Visible = False
End If
End Sub
Private Sub UserForm_Initialize()
If Workbooks.Count > 1 Then
Windows("Test.xlsm").Visible = False
Else
Application.Visible = False
End If
End Sub
Private Sub UserForm_Terminate()
If Workbooks.Count > 1 Then
Windows("Test.xlsm").Visible = True
Else
Application.Visible = True
End If
End Sub
This will only show or hide the form's workbook. Any other workbooks opened will remain unaffected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.