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??
 
Do you have Trusted Acc ess to VBA projects set? This would be my guess.

Is the project password protected?

Is the project password protected? NO

Do you have Trusted Acc ess to VBA projects set? I don't understand your question
Acc ess?
project set?



PS: Thanks!
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Goto Tools>Macro>Security...>Trusted Publishers, make sure that the Trust Acces to Visual Basic Projects is checked.
 
Upvote 0
Goto Tools>Macro>Security...>Trusted Publishers, make sure that the Trust Acces to Visual Basic Projects is checked.


[SOLVED]

Many Thanks!!!!!
 
Upvote 0
Do you have Trusted Acc ess to VBA projects set? This would be my guess.

Is the project password protected?

I have found a solution to this too


If you are using Excel 2007/2010, you need to add the VBA project as trusted publisher by following this step:

Click on File tab, choose Options
in Excel Option dialog, choose Trust Center
then click on Trust Center Settings button
in Macro settings pane, check the Trust access to the VBA project object model

then click OK button to close the dialog.

Hope this will help some Malaysian. Have a nice day.

Many thanks to CPearson for writing a detailed article to use VBA
Programming In The VBA Editor
 
Upvote 0

Forum statistics

Threads
1,215,945
Messages
6,127,851
Members
449,411
Latest member
adunn_23

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