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


Hi,

I have serious problem with accessing VBProject of another Excel workbook.
I need to play with VBComponents and check CodeNames of all sheets.
Always when code refers to VBProject of another workbook error 1004 mentioned in subject of this post is generated.

Notes:
- “Trust access to the VBA project object model” is set on in Trust Center / Macro setting
- reference to “Microsoft Visual Basic for Application Extensibility 5.3” is added
- opened file is located in network drive

Below there is part of code in VBA.
Do you know what can be the reason of that problem?

Private Sub Test()

Dim MyFiles As Variant
Dim Fnum As Byte
Dim mybook As Workbook
Dim mybookProject As VBIDE.VBProject
Dim VBC As VBIDE.VBComponent

MyFiles = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", MultiSelect:=True)

If IsArray(MyFiles) Then

For Fnum = LBound(MyFiles) To UBound(MyFiles)
Set mybook = Application.Workbooks.Open(MyFiles(Fnum), , True)

‘***** next line an error occurs ******
Set mybookProject = mybook.VBProject
For Each VBC In mybookProject.VBComponents
If VBC.Type = 100 Then
...
...

Kind regards,
Marcin
 
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 07:18 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"