[英]How to detect open Excel files in a macro Excel?
How can I detect all open Excel files and run through them, in order to lock their sheets?如何检测所有打开的 Excel 文件并运行它们,以锁定它们的工作表?
I have an Excel file containing the macro.我有一个包含宏的 Excel 文件。 Once it is launched, it would go through all my open excel files, and lock their sheets by setting a password.
启动后,它将遍历我所有打开的 excel 文件,并通过设置密码锁定它们的工作表。
Just don't know how to detect open Excel files from VBA.只是不知道如何从 VBA 检测打开的 Excel 文件。
You just have to loop on the workbooks in Application
:您只需要在
Application
循环工作簿:
Dim wB as WorkBook
Dim wS as WorkSheet
For Each wB in Application.WorkBooks
For Each wS in wB.Sheets
wS.Protect "password"
Next wS
Next wB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.