open file macros inactive

A

Alberto Ast

I need to open a file read only and macros inactive.

I know how to do read only but how to do macros inactives?
 
B

Barb Reinhardt

Put this around your workbook open code

Application.AutomationSecurity = msoAutomationSecurityLow
'Workbook open code
Application.AutomationSecurity = msoAutomationSecurityByUI

HTH,
Barb Reinhardt
 
A

Alberto Ast

Barb,

Wouldn't this affect my main file macros? I need to open the second file
with macros inactive... will below do it and still keep my master file macros
active. Please calrify.
 
B

Barb Reinhardt

If you do this

Application.AutomationSecurity = msoAutomationSecurityForceDisable

Your macros will stop altogether.

Just try it and step through the code to see if it works. I guarantee it
will. You won't get an enable macro message and any workbook open code that
you have will not run.

Isn't that what you want?
 
A

Alberto Ast

Thanks Barb.. it did open with macros disable but my initial macro where I
open the file stop there after opening a file... it did not perform the rest
of the macro... how do I enable it again so it will continue.

Thanks,
 
A

Alberto Ast

I removed all the Application.Automa..... comand lines I previously posted so
for now the macro will finish all the way but it acts as if I had not removed
the Applicaion.AutomationSecu..... command... it open the file and then
stop... I have this

Sub OpenFile()
Workbooks.Open Filename:="MyFile.xls", ReadOnly:=True
Workbooks("MyFile.xls").Close savechanges:=False
Windows("File_with_original_macro.xls").Activate
End Sub
 

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