Hide Workbook

A

aftamath77

I would like to write code that will hide a specific workbook when a userform
pops up. I tried:

Application.Visible = False

That works fine except, it hides Excel completely. I would like to hide
only the workbook that contains the userform.
 
D

Dave Peterson

The workbook that contains the userform?

dim myWindow as window
for each mywindow in thisworkbook.windows
mywindow.visible = false
next mywindow

Change
thisworkbook.windows
to
activeworkbook.windows
if you want the activeworkbook's windows hidden.

===
If there's only one window for that workbook:
thisworkbook.windows(1).visible = false
 
I

IanC

Worksheets("Sheet1").Visible = False

Bear in mind that Excel must have at least one worksheet visible.

Another alternative might be to reduce the window size so it is hidden
behind the userform.

Assuming the code is in the active worksheet:

With ActiveWindow
.WindowState = xlNormal
.Top = 100
.Left = 250
.Height = 100
.Width = 100
End With
UserForm1.Show
 
S

Sheeloo

Try this from another workbook
Workbooks("WkbNameHere").window(1).hidden = True

or

Windows("WkbNameHere.xls").Visible = False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top