Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Application.AutomationSecurity stops calling macro

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Application.AutomationSecurity stops calling macro

Try using
Application.DisableEvents = True
' open file
Application.DisableEvents = False


--

Regards,
Nigel




"JohnH" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Application.AutomationSecurity stops calling macro

Oops sorry, my logic!

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

--

Regards,
Nigel




"Nigel" wrote in message
...
Try using
Application.DisableEvents = True
' open file
Application.DisableEvents = False


--

Regards,
Nigel




"JohnH" wrote in message
...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Application.AutomationSecurity stops calling macro

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" wrote in message
...
Oops sorry, my logic!

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

--

Regards,
Nigel




"Nigel" wrote in message
...
Try using
Application.DisableEvents = True
' open file
Application.DisableEvents = False


--

Regards,
Nigel




"JohnH" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling an application from excel SatyanarayanaS Excel Worksheet Functions 1 May 14th 08 02:50 PM
VBA calling a web application that returns XML stainless Excel Programming 4 June 1st 07 11:51 AM
Code Halt - prevents reset of the AutomationSecurity level Walt[_3_] Excel Programming 8 March 24th 05 06:55 PM
Problems calling a procedure in another application msk19[_3_] Excel Programming 1 September 14th 04 12:49 PM
calling an Excel Add-in application McNiwram Excel Programming 2 December 19th 03 02:39 PM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"