PC Review


Reply
Thread Tools Rate Thread

Application.AutomationSecurity stops calling macro

 
 
JohnH
Guest
Posts: n/a
 
      1st Feb 2008
Excel 2003 SP3, Vista, Macro Security et to 'Medium'

I'm trying to automatically check several hundered files, however many have
VBA including Workbook_Open events that I need to surpress. However my code
simply stops ALL macro execution including the calling macro once the
workbook is opened.

In a test file, a basic Workbook_Open event is entered, and the file saved
as Test.xls, then closed

Private Sub Workbook_Open()
MsgBox "Hello World"
End Sub

In another workbook the following macro is entered ....

Sub OpenFileTest()
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Workbooks.Open "c:\Test.xls"
Application.AutomationSecurity = msoAutomationSecurityLow
MsgBox "Done"
End Sub

If the OpenFileTest sub is run WITHOUT the
'msoAutomationSecurityForceDisable' line, then as expected the new file is
opened, followed by two message boxes, "Hello World", then "Done", but if
the 'msoAutomationSecurityForceDisable' is included the Test file is opened
then the macro just stops and I am returned to design mode.

I have also tried it in Excel 2002 (exactly the same behaviour), but on a
friends Excel 2007 it works perfectly (ie only the "Done" message box is
diplayed (sorry ... no I can't just run the code on that machine!!). I'm at
my wits end ... does anyone have any experience of this or would be so kind
to replicate the problem and let me know if it works for them or I'm missing
something simple.

John



 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      2nd Feb 2008
Try using
Application.DisableEvents = True
' open file
Application.DisableEvents = False


--

Regards,
Nigel
(E-Mail Removed)



"JohnH" <(E-Mail Removed)> wrote in message
news:2DC96C26-C40E-4245-A60A-(E-Mail Removed)...
> Excel 2003 SP3, Vista, Macro Security et to 'Medium'
>
> I'm trying to automatically check several hundered files, however many
> have VBA including Workbook_Open events that I need to surpress. However
> my code simply stops ALL macro execution including the calling macro once
> the workbook is opened.
>
> In a test file, a basic Workbook_Open event is entered, and the file saved
> as Test.xls, then closed
>
> Private Sub Workbook_Open()
> MsgBox "Hello World"
> End Sub
>
> In another workbook the following macro is entered ....
>
> Sub OpenFileTest()
> Application.AutomationSecurity = msoAutomationSecurityForceDisable
> Workbooks.Open "c:\Test.xls"
> Application.AutomationSecurity = msoAutomationSecurityLow
> MsgBox "Done"
> End Sub
>
> If the OpenFileTest sub is run WITHOUT the
> 'msoAutomationSecurityForceDisable' line, then as expected the new file
> is opened, followed by two message boxes, "Hello World", then "Done", but
> if the 'msoAutomationSecurityForceDisable' is included the Test file is
> opened then the macro just stops and I am returned to design mode.
>
> I have also tried it in Excel 2002 (exactly the same behaviour), but on a
> friends Excel 2007 it works perfectly (ie only the "Done" message box is
> diplayed (sorry ... no I can't just run the code on that machine!!). I'm
> at my wits end ... does anyone have any experience of this or would be so
> kind to replicate the problem and let me know if it works for them or I'm
> missing something simple.
>
> John
>
>
>


 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      2nd Feb 2008
Oops sorry, my logic!

Application.EnableEvents = False
' open file
Application.EnableEvents = True

--

Regards,
Nigel
(E-Mail Removed)



"Nigel" <nigel-(E-Mail Removed)> wrote in message
news:B9D8A265-B8A2-466E-ACE1-(E-Mail Removed)...
> Try using
> Application.DisableEvents = True
> ' open file
> Application.DisableEvents = False
>
>
> --
>
> Regards,
> Nigel
> (E-Mail Removed)
>
>
>
> "JohnH" <(E-Mail Removed)> wrote in message
> news:2DC96C26-C40E-4245-A60A-(E-Mail Removed)...
>> Excel 2003 SP3, Vista, Macro Security et to 'Medium'
>>
>> I'm trying to automatically check several hundered files, however many
>> have VBA including Workbook_Open events that I need to surpress. However
>> my code simply stops ALL macro execution including the calling macro once
>> the workbook is opened.
>>
>> In a test file, a basic Workbook_Open event is entered, and the file
>> saved as Test.xls, then closed
>>
>> Private Sub Workbook_Open()
>> MsgBox "Hello World"
>> End Sub
>>
>> In another workbook the following macro is entered ....
>>
>> Sub OpenFileTest()
>> Application.AutomationSecurity = msoAutomationSecurityForceDisable
>> Workbooks.Open "c:\Test.xls"
>> Application.AutomationSecurity = msoAutomationSecurityLow
>> MsgBox "Done"
>> End Sub
>>
>> If the OpenFileTest sub is run WITHOUT the
>> 'msoAutomationSecurityForceDisable' line, then as expected the new file
>> is opened, followed by two message boxes, "Hello World", then "Done", but
>> if the 'msoAutomationSecurityForceDisable' is included the Test file is
>> opened then the macro just stops and I am returned to design mode.
>>
>> I have also tried it in Excel 2002 (exactly the same behaviour), but on a
>> friends Excel 2007 it works perfectly (ie only the "Done" message box is
>> diplayed (sorry ... no I can't just run the code on that machine!!). I'm
>> at my wits end ... does anyone have any experience of this or would be so
>> kind to replicate the problem and let me know if it works for them or I'm
>> missing something simple.
>>
>> John
>>
>>
>>

>


 
Reply With Quote
 
JohnH
Guest
Posts: n/a
 
      2nd Feb 2008
Thanks for that Nigel ...

Yes in hindsight the whole Application.AutomaticSecurity method (disabling
all macros in the workbook) is overkill for my needs and your solution works
perfectly.

Kind regards
John

"Nigel" <nigel-(E-Mail Removed)> wrote in message
news:96EEF8A2-287E-4F4E-A4A0-(E-Mail Removed)...
> Oops sorry, my logic!
>
> Application.EnableEvents = False
> ' open file
> Application.EnableEvents = True
>
> --
>
> Regards,
> Nigel
> (E-Mail Removed)
>
>
>
> "Nigel" <nigel-(E-Mail Removed)> wrote in message
> news:B9D8A265-B8A2-466E-ACE1-(E-Mail Removed)...
>> Try using
>> Application.DisableEvents = True
>> ' open file
>> Application.DisableEvents = False
>>
>>
>> --
>>
>> Regards,
>> Nigel
>> (E-Mail Removed)
>>
>>
>>
>> "JohnH" <(E-Mail Removed)> wrote in message
>> news:2DC96C26-C40E-4245-A60A-(E-Mail Removed)...
>>> Excel 2003 SP3, Vista, Macro Security et to 'Medium'
>>>
>>> I'm trying to automatically check several hundered files, however many
>>> have VBA including Workbook_Open events that I need to surpress. However
>>> my code simply stops ALL macro execution including the calling macro
>>> once the workbook is opened.
>>>
>>> In a test file, a basic Workbook_Open event is entered, and the file
>>> saved as Test.xls, then closed
>>>
>>> Private Sub Workbook_Open()
>>> MsgBox "Hello World"
>>> End Sub
>>>
>>> In another workbook the following macro is entered ....
>>>
>>> Sub OpenFileTest()
>>> Application.AutomationSecurity = msoAutomationSecurityForceDisable
>>> Workbooks.Open "c:\Test.xls"
>>> Application.AutomationSecurity = msoAutomationSecurityLow
>>> MsgBox "Done"
>>> End Sub
>>>
>>> If the OpenFileTest sub is run WITHOUT the
>>> 'msoAutomationSecurityForceDisable' line, then as expected the new file
>>> is opened, followed by two message boxes, "Hello World", then "Done",
>>> but if the 'msoAutomationSecurityForceDisable' is included the Test
>>> file is opened then the macro just stops and I am returned to design
>>> mode.
>>>
>>> I have also tried it in Excel 2002 (exactly the same behaviour), but on
>>> a friends Excel 2007 it works perfectly (ie only the "Done" message box
>>> is diplayed (sorry ... no I can't just run the code on that machine!!).
>>> I'm at my wits end ... does anyone have any experience of this or would
>>> be so kind to replicate the problem and let me know if it works for them
>>> or I'm missing something simple.
>>>
>>> John
>>>
>>>
>>>

>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.AutomationSecurity command and Access 2003 J Baird Microsoft Access Macros 1 28th Apr 2006 11:19 AM
automationsecurity =?Utf-8?B?c2tjaHRo?= Microsoft Access Security 5 22nd Mar 2006 01:23 AM
automationsecurity Redbeard Microsoft Access 2 4th Oct 2005 08:26 PM
Calling an access Macro from a VB.NET application - Very Urgent Sen K via .NET 247 Microsoft VB .NET 1 16th Apr 2004 09:02 AM
Phone dialer stops dialing too soon when using custom calling card. pj Microsoft Outlook 0 22nd Dec 2003 04:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:42 AM.