0
votes

I have an excel (2013) file that automatically opens a userform. I want it to show only the userform and hide only that one specific workbook, but it either hides all the workbooks that were open before or show all of them, including the one I want hidden. I tried to use:

Application.visible = false

With ActiveWindow
Application.visible=false
End with

ActiveWindow.application.visible = false

ActiveWindow.visible = false

Windows("workbookname.xlsm").visible = false

None worked. If anyone has any idea I'd be very thankfull. Thank you.

1

1 Answers

0
votes

This hides and shows a specific workbook, even if other workbooks are open:

Sub test()
    Dim wb As Workbook
    Set wb = Workbooks("Myworkbook.xlsm")
    wb.Windows(1).Visible = False
    'code
    wb.Windows(1).Visible = True
End Sub

Note that the workbook has to be open for this to work. If not opened yet, use:

Set wbk = Workbooks.Open("Myworkbook.xlsm")