LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default EX2007 - Error 1004: method 'VBProject' of object '_Workbook' failed

aditel submitted this idea :
I found out what was reason of the problem with error 1004.
It was security level of macros that by default is set to "Disable all macros
with notification". So when workbook was opened and code was running, it was
not possible to get to VBProject object when macros in the workbook are not
enabled.

Solution for that is to read value of AutomationSecurity, then change it to
Low level, open workbook, do necessary actions, close workbook and finally
back to origional AutomationSecurity setting before file was opened.

SecurityLevel = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityLow

...
code lines
...

Application.AutomationSecurity = SecurityLevel


This suggests that this property was altered (by code at some point) as
the default Excel setting is 'msoAutomationSecurityLow' and works fine
regardless of what UI security settings are in place.

Note that automated instances of Excel have no security settings at
all. I suspect this is the reason why the AutomatedSecurity default is
'msoAutomationSecurityLow'.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
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
Run-time error 1004 Method SaveAS of object _Workbook failed David Excel Programming 2 December 18th 08 08:38 PM
method 'SaveAs' of object '_Workbook' failed Kishi Excel Programming 1 July 12th 06 03:51 AM
Method 'CheckIn' of object '_workbook' failed Bill Schanks Excel Programming 1 May 9th 06 10:04 PM
Error 1004 Method 'Add'of Object Sheets failed ExcelMonkey[_190_] Excel Programming 10 March 29th 05 01:52 PM
Error 1004: Method 'Cells' of object '_Global' failed LT Excel Programming 2 October 31st 03 04:47 PM


All times are GMT +1. The time now is 06:56 PM.

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"