Automation Security and unexpected program termination

A

Arne

I want to open an Excel workbook which I know is read-only (password
protected), and contains code. To load the file and to disable the code, I set
Application.AutomationSecurity = msoAutomationSecurityForceDisable, and then
open the workbook:
Application.Workbooks.Open Filename:=strFileName,
WriteResPassword:=strWriteResPassw
This works, but also the code execution stops without any error messages. Is
this the expected result of this sequence? The problem does not occur when I
do not alter the default automationsecurity setting.
 
J

joel

why not open the workbook in read only mode?

Application.Workbooks.Open Filename:=strFileName, Readonly:=tru
 
A

Arne

Because I want the user be able to edit the file conveniently (without the
events being triggered, which is why I want the vba code on the file
disabled, but disabling events is not an option, because I want them to
remain active on other open files) and save it under the original name.
 
A

Arne

It's almost as if the code that is being executed (which is, by the way, in
an add-in) switches itself off. It also happens when I choose to switch off
the macro attached to the file to be opened via the UI that appears when I do
not set the automation security. However, when I choose to activate the macro
at that point, the code execution does continue without problems. When I
place an 'on error resume next' statement before the line where the file is
opened, the problem remains.
 
J

joel

You can open the workbook in safe mode which doesn't run any macros bu
still allow changes to be made. the only way I know of opening i
safemode is from the command line prompt using /s.


Comspec = Environ("Comspec")
ExcelExe = Application.Path & "\excel.exe"
FName = "c:\temp\book1.xls"

CommandLine = Comspec & " /k " & Chr(34) & _
ExcelExe & Chr(34) & " /s " & FName

Shell (CommandLine
 

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