copying modules from one workbook to another workbook

V

Vinod

I'm having 2 workbooks. I wanted to copy some of the modules from workbook1
to workbook2.

Note: Both workbooks are opend.

Please help me out by providing relavent VBA code.

Advanced Thanks,
Vinod
 
G

Gord Dibben

Right-click on a module in book1 and Export as a *.bas file.

In book2 right-click on a module and Import File

Do this a few times and you've got the modules copied.

To do it programmatically see Chip Pearson's site

http://www.cpearson.com/excel/VBE.aspx

Copy A Module From One Project To Another


Gord Dibben MS Excel MVP
 
V

Vinod

Thanks Gord Dibben.

I captured code from provided link and I achieved it partly which is failing
in saving file after copying code from a module to 'Thisworkbook' and deleted
unnecessary modules.

At the end of copy and delete process I've wrorte like this: thisworkbook.save
while executing 'save' statement I got a message saying that 'Document not
save' with 'Ok' option.

Is there any workaround for this.
Please share your thoughts and relavent code which will be appreciated.

Advanced Thanks,
Vinod
 

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