How to block all macro when a particular file is open

  • Thread starter Thread starter Dileep Chandran
  • Start date Start date
D

Dileep Chandran

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
 
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
 

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

Back
Top