Create New Workbook and add VBA Code to using VBA

R

Rligouri

I have and excel workbook that uses VBA to create another workbook.
There is also some vba code that I would like included in the new
workbook. What is the best way to achieve that?
 
C

Chip Pearson

You can use code to create and modify other code by using the objects and
methods that are part of the Extensibility library. See
www.cpearson.com/Excel/VBE.aspx for details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
D

Dave Peterson

I think I would create a template workbook (*.xlt) and use that as a basis for
the new workbook.

Then I'd use something like:

Dim NewWkbk as workbook
set newwkbk = workbooks.add(template:="C:\yourtemplate.xlt")

I think you'll find that life is lots easier if you don't have to worry about
security settings and importing the code (or copying from one workbook to
another).

But if you want to try this, check out Chip Pearson's site:
http://cpearson.com/excel/vbe.aspx
 

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