代码只隐藏一个工作簿,而不是隐藏所有当前打开的工作簿 [英] Code to hide only one workbook instead of hiding all currently open workbooks
问题描述
以下是我尝试过的代码:
ThisWorkbook.Application.Visible = False
Windows(ThisWorkbook.name).Visible = False
Application.Windows(1).visible = false
使用 Windows(ThisWorkBook.name).visible = False
只关闭一个工作簿,它与工作簿混乱,工作表完全不显示。我不能关闭excel工作簿,而不使用任务管理器。
ThisWorkbook.Application。 Visible = False
将更改运行工作簿的应用程序的 Visible
属性,即Excel.EXE的一个实例。如果这个实例还在运行其他书籍,那么所有这些书籍都将从屏幕上消失。
要隐藏单个工作簿,请使用
ActiveWindow.Visible = False
或者如果要隐藏的工作簿(例如MyWorkbook)不是活动的
Windows(MyWorkbook)Visible = False
注意,隐藏窗口也会将指针移动到ActiveSheet,同样当你反转这个(即 ... Visible = True
)时,显示的表单变为活动。
I usually have multiple workbooks open and on one workbook, I have a VBA code that hides the workbook and shows a UserForm. But when I open that workbook, all of my workbooks that are currently opened will also hide. What code can I use to just hide 1 workbook?
Here are the codes I've tried:
ThisWorkbook.Application.Visible = False
Windows(ThisWorkbook.name).Visible = False
Application.Windows(1).visible = false
With Windows(ThisWorkBook.name).visible = False
works with closing only one workbook, it messes with the workbook and the sheets don't show at all. I can't even close the excel workbook without using the task manager.
ThisWorkbook.Application.Visible = False
will change the Visible
property of the application running your workbook, i.e. an instance of Excel.EXE ... if this instance is running your other books, too, then as a consequence all these books will disappear from screen.
To hide a single workbook, use
ActiveWindow.Visible = False
or alternatively, if the workbook you want to hide (e.g. "MyWorkbook") is not the active one
Windows("MyWorkbook").Visible = False
Pay attention that hiding a window also moves the pointer to the ActiveSheet, likewise when you reverse this (i.e. ...Visible = True
) the displayed sheet becomes active.
这篇关于代码只隐藏一个工作簿,而不是隐藏所有当前打开的工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!