ActiveWorkbook.VBProject VBComponents

drom

Well-known Member
Joined
Mar 20, 2005
Messages
528
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Thanks in advance!

I already know this web:

http://www.cpearson.com/excel/vbe.aspx

I have checked the following reference whithin Excel VBA's references Manually:

Microsoft Visual Basic for Applications Extensibility 5.3


BUT when I run the following Macro, once checked the prior reference:

Code:
Sub AddModuleToProject()
  On Error Resume Next
      Debug.Print Err           ' I GET 0
Dim VBProj As VBIDE.VBProject:      Set VBProj = ActiveWorkbook.VBProject
      Debug.Print Err           ' I GET 1004
Dim VBComp As VBIDE.VBComponent:    Set VBComp = VBProj.VBComponents.Add(vbext_ct_StdModule)
      Debug.Print Err           ' I GET 91
    VBComp.Name = "NewModule"
      Debug.Print Err           ' I GET 91
End Sub


Why I get those errors.

What am I Missing??
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I have been using code like this for a big while in my office.

not at home.

In my office I don't get any err


At home YES.


this is the reason Why I am asking what am I missing

Thanks!
 
Upvote 0
Is the Microsoft Visual Basic for Applications Extensibility library active in the erroring environment?

If not, dimming the variables as Object might set things right.
 
Upvote 0
Is the Microsoft Visual Basic for Applications Extensibility library active in the erroring environment?

If not, dimming the variables as Object might set things right.



Is the Microsoft Visual Basic for Applications Extensibility library active? YEs it is active, Checked.

in the erroring environment? Don't know what you mean

I run the macro after checking the reference first.
 
Upvote 0
By "in the erroring environment", I meant at home, where you get the errror. At work, it looks like the library is active.
 
Upvote 0
By "in the erroring environment", I meant at home, where you get the errror. At work, it looks like the library is active.



In both places at home and in my office the reference is active!

so, I don't understant?

Thanks!
 
Upvote 0
Have you tried specifying the workbook explicitly rather than using ActiveWorkbook?
 
Upvote 0
Do you have Trusted Acc ess to VBA projects set? This would be my guess.

Is the project password protected?
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,281
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top