Problem copying Macro to external Workbook

pingme89

Board Regular
Joined
Jan 23, 2014
Messages
170
Office Version
  1. 365
Platform
  1. Windows
I have the following code that should copy a macro in the current workbook to another workbook I just created from VBA code.

Const MODULE_NAME As String = "ShowE" ' Name of the module to transfer
Const TEMPFILE As String = "c:\Modul.bas" ' temp textfile


Rem ** export the module to a textfile
Application.Workbooks(WBN).VBProject.VBComponents("ShowE").Export TEMPFILE

'import the module to the new workbook
Application.Workbooks(WBNameX).VBProject.VBComponents.Import TEMPFILE

'kill the textfile
Kill TEMPFILE


I get the following error message:

Run-Time error '1004'

Programmatic access to Visual Basic Project is not trusted

I think I need to make a self-signed certificate but I am not sure how to do it from Powershell.
I am running Windows 10 and Powershell should be built-in.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
File -> Options -> Trust Center -> Trust Center Settings -> Macro Settings -> Trust Access to the VBA project object model
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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