View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Walt[_3_] Walt[_3_] is offline
external usenet poster
 
Posts: 48
Default Code Halt - prevents reset of the AutomationSecurity level

Hi Simon,

It's nice to have confirmation, though I'd been hoping the
documentation neglected to mention some library reference I should
establish.

The idea of "disabling events and calculation" had not occurred to me,
and I can see that might be OK if I just wanted to read some content
and then close the file.

Thank you.

Best Regards,
Walt Weber


Simon Murphy wrote:
Walt
I had the same problem
In the end I compiled the caller into a VB6.0 exe which worked fine.

It
does seem to halt the whole of vba.
In the vba version I stripped the automationSecurity stuff and relied

on
disabling events and calculation, on the basis that this would stop

any code
being triggered.

cheers
Simon

"Walt" wrote:

Hi,

Starting with a copy of the sample from the help system, I modified

it
slightly as you can see below. I find that not only is the code

in an
unsigned project prevented from running (As intended), but all

code,
even in the project 'controlling' the open, is immediately halted.
This prevents the reset of the AutomationSecurity level.

'MODIFIED FROM VBA HELP SAMPLE
Sub Security() 'TEST WITH SECURITY DG SET TO HIGH
Dim secAuto As MsoAutomationSecurity
secAuto = Application.AutomationSecurity

'MODIFIED FROM FORCEDISABLE TO ByUI
Application.AutomationSecurity = msoAutomationSecurityByUI
'MODIFIED THIS LINE
Application.Dialogs(xlDialogOpen).Show

'CODE HALTS, & NEVER GETS TO NEXT LINE
'IF ANY FILES OPENED HAVE CODE
'PREVENTED FROM RUNNING BY THE
'MACRO SECURITY
Application.AutomationSecurity = secAuto
End Sub

Does anyone know a better way to do this?

Best Regards,
Walt Weber