PC Review


Reply
Thread Tools Rate Thread

copy Module via macro

 
 
=?Utf-8?B?TWlyaQ==?=
Guest
Posts: n/a
 
      17th Sep 2007

hi,
i need to add a module via macro.
what i did before is adding a new module, define the name and added the code
as string... as you can see below:
Set xlModule = Application.VBE.ActiveVBProject.VBComponents.Add(1)
xlModule.Name = "SetConfigTo" & config & "_"
Code = "Sub SetConfigTo" & config & "()" & vbCr & " ...& "End Sub"
xlModule.codemodule.addfromstring Code

now i need to copy module from other project. the code is about 1000 lines.
do you know a better way to do that?
thanks.

--
Miri Tz.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      17th Sep 2007
see good examples for doing a variety of work in this area here:

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

--
Regards,
Tom Ogilvy


"Miri" wrote:

>
> hi,
> i need to add a module via macro.
> what i did before is adding a new module, define the name and added the code
> as string... as you can see below:
> Set xlModule = Application.VBE.ActiveVBProject.VBComponents.Add(1)
> xlModule.Name = "SetConfigTo" & config & "_"
> Code = "Sub SetConfigTo" & config & "()" & vbCr & " ...& "End Sub"
> xlModule.codemodule.addfromstring Code
>
> now i need to copy module from other project. the code is about 1000 lines.
> do you know a better way to do that?
> thanks.
>
> --
> Miri Tz.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a public module macro in private module macro emmanuel Webmaster / Programming 1 13th May 2011 06:34 PM
How to Copy a VB Module Ken Hudson Microsoft Excel Programming 7 21st Dec 2009 06:59 PM
COPY MODULE MACRO WITH WORKSHEET TO OTHER WORKBOOKS K Microsoft Excel Programming 2 19th Feb 2008 05:34 PM
Macro to change macro or module level const that is calculated Ren Microsoft Excel Programming 1 28th Nov 2007 10:23 PM
How do I copy a new module to 200 workbooks with a macro? Patrick Young Microsoft Excel Worksheet Functions 1 3rd Sep 2005 04:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:27 AM.