Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel Macro error in Add method of object _VBcomponents

I have a macro that adds a code module in EXCEL It works fine in EXCEL 97.
Now I am using it in EXCEL 2003 ant it fails (runtime 440) with the message
"error in Add method of object _VBcomponents"
The code is:

With Application.VBE.ActiveVBProject

' Create and use a new module
With .VBComponents.Add(vbext_ct_StdModule) <== This is the offending code
line

"Add" gives an error
' Change the module name
.Name = "ModuloDeMacrosDelIndice"
' Use the code module
With .CodeModule
' Add the contents of a file
.AddFromFile Archivo$

End With

Any help will be welcome

Cap Kirk


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Excel Macro error in Add method of object _VBcomponents

Cap'n,

Your code worked fine for me in Excel 2003.

HTH,
Bernie
MS Excel MVP


"Cap Kirk" wrote in message ...
I have a macro that adds a code module in EXCEL It works fine in EXCEL 97.
Now I am using it in EXCEL 2003 ant it fails (runtime 440) with the message
"error in Add method of object _VBcomponents"
The code is:

With Application.VBE.ActiveVBProject

' Create and use a new module
With .VBComponents.Add(vbext_ct_StdModule) <== This is the offending code
line

"Add" gives an error
' Change the module name
.Name = "ModuloDeMacrosDelIndice"
' Use the code module
With .CodeModule
' Add the contents of a file
.AddFromFile Archivo$

End With

Any help will be welcome

Cap Kirk




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macro error in Add method of object _VBcomponents

Did you check 'enable programmatic access to vba" somewhere in the macro
security settings (I'm on 2007, can't check exact location)?
Jurgen

"Cap Kirk" wrote in message
...
I have a macro that adds a code module in EXCEL It works fine in EXCEL 97.
Now I am using it in EXCEL 2003 ant it fails (runtime 440) with the
message
"error in Add method of object _VBcomponents"
The code is:

With Application.VBE.ActiveVBProject

' Create and use a new module
With .VBComponents.Add(vbext_ct_StdModule) <== This is the offending
code
line

"Add" gives an error
' Change the module name
.Name = "ModuloDeMacrosDelIndice"
' Use the code module
With .CodeModule
' Add the contents of a file
.AddFromFile Archivo$

End With

Any help will be welcome

Cap Kirk


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel Macro error in Add method of object _VBcomponents

Dear Jurgen:

In EXCEL 2003 I checked:

Tools = Options = Safety = Macro Safety = Safety Level (First Tab) :
medium
Tools = Options = Safety = Macro Safety = Trusted Sources (Second Tab)
= Check "Trust Visual Basic Projects access" and also "Trust all
Complements and Templates installed"

Dear Bernie:

My code, which is exactly as published, in EXCEL 2003 with OS Win2K, does
not work

The runtime error 404 appears and the second line says the .Add method does
not work with object _VBcomponents

???? any clue on how to debug this? How con I track how the Add method is
working?

Thank You very much. Any help is welcome.

Cap Kirk



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel Macro error in Add method of object _VBcomponents - SOLVED

I found the culprit.

The "MS VBA EXTENSIBILITY 5.3 " library was NOT referenced.
I went to the VBA editor (EXCEL=Tools=Macros=VBA Editor) and there again:
Tools=References and checked the library.

Now the macro is alive again. Thanks to everybody that tried to help me.

Cap Kirk




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Excel Macro error in Add method of object _VBcomponents - SOLVED

When I removed the reference to VBA extensibility, I got a different error
than what you reported - a constant (vbext_ct_StdModule) not defined. It
always pays to use Debug / Compile on your code to find errors like that.
Try setting your Tools / Options, General Tab "Compile on demand" and you
will get better error messages.

Bernie


"Cap Kirk" wrote in message
...
I found the culprit.

The "MS VBA EXTENSIBILITY 5.3 " library was NOT referenced.
I went to the VBA editor (EXCEL=Tools=Macros=VBA Editor) and there
again:
Tools=References and checked the library.

Now the macro is alive again. Thanks to everybody that tried to help me.

Cap Kirk




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
Object doesn't support this property or method (Error 438) gazza67[_2_] Excel Programming 2 August 9th 07 02:30 AM
Error in Macro: "Method 'Paste' of object '_Worksheet' failed" blork Excel Programming 7 March 5th 06 05:48 PM
VBA error 438 - Object not supporting this property or method Catalina Excel Programming 1 December 7th 05 10:51 PM
Object doesn't support this property or method (Error 438) Kiran Excel Discussion (Misc queries) 1 July 12th 05 08:42 PM
Object range method runtime error Neal Zimm Excel Programming 3 April 8th 05 02:47 AM


All times are GMT +1. The time now is 11: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"