ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to block all macro when a particular file is open (https://www.excelbanter.com/excel-programming/379848-how-block-all-macro-when-particular-file-open.html)

Dileep Chandran

How to block all macro when a particular file is open
 
Hello everybody,

Is there a way to block all the macros, when Test.xls is opened. I dont
want users to run macro in any excel file, with Test.xls kept open.

Any help is really appreciated. Thanks in advance !

-Dileep


Dave Peterson

How to block all macro when a particular file is open
 
You could add this to the top of every macro that shouldn't be allowed:

dim Wkbk as workbook
set wkbk = nothing
on error resume next
set wkbk = workbooks("test.xls")
on error goto 0

if wkbk is nothing then
'ok
else
msgbox "Please close test.xls first"
exit sub
end if



Dileep Chandran wrote:

Hello everybody,

Is there a way to block all the macros, when Test.xls is opened. I dont
want users to run macro in any excel file, with Test.xls kept open.

Any help is really appreciated. Thanks in advance !

-Dileep


--

Dave Peterson


All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com