Use VBA to copy macros from one workbook to another

D

Dean@ERYC

I have a 'master' workbook which opens other 'Data' workbooks and does
various calculations/data validations on these workbooks. Before saving the
'Data' workbooks a Module from the master containing several macros is copied
across to the 'Data' spreadsheet. The code below works in Excel 2000 but not
in 2003.

It displays an error:
Run-time error '1004':
Programmatic access to Visual Basic Project is not trusted

'copy macro to validated wookbook
Dim FName As String
With Workbooks("TEAMS_Master.xls")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module9").Export FName
End With
Workbooks("IDBev.xls").VBProject.VBComponents.Import FName

Thanks for your help,
Dean.
 
N

Norman Jones

Hi Dean,

Try:

Tools | Macro | Security |Trusted Publisher Tab
[x] Trust access to Visual Basic Project
 
J

Jim Thomlinson

Starting in XL2002 the idea of trusted sources for macros began. In XL 2003
select Tools -> Macros -> Security -> Trusted Sources and check Trust Access
to Visual Basic Project.
 
D

Dean@ERYC

Thanks for your quick reply, - It's nice when it't something so simple! I had
visions of having to recode half of the 10,000 lines in the workbook!!

Thanks, Dean.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top