Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Use VBA to copy macros from one workbook to another

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.Impo rt FName

Thanks for your help,
Dean.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Use VBA to copy macros from one workbook to another

Hi Dean,

Try:

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



---
Regards.
Norman
"Dean@ERYC" wrote in message
...
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.Impo rt FName

Thanks for your help,
Dean.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Use VBA to copy macros from one workbook to another

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.
--
HTH...

Jim Thomlinson


"Dean@ERYC" wrote:

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.Impo rt FName

Thanks for your help,
Dean.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Use VBA to copy macros from one workbook to another

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.

"Jim Thomlinson" wrote:

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.
--
HTH...

Jim Thomlinson


"Dean@ERYC" wrote:

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.Impo rt FName

Thanks for your help,
Dean.

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
Copy workbook without Macros Robert[_34_] Excel Programming 1 February 15th 07 01:44 AM
How to copy a workbook so the buttons run the macros? - Excel Discussion (Misc queries) 4 May 15th 05 11:24 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Open workbook-macros enabled, opening another with macros George J Excel Programming 5 September 17th 04 02:07 PM
Copy Macros and VB code from one workbook to another Dawn[_2_] Excel Programming 1 December 2nd 03 11:03 PM


All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"