Import "ThisWorkbook"?

C

Charlotte E.

When I right-click and export the "ThisWorkbook" class module everything
works fine :)

But when I try to import it again it gets imported a a new seperate
class-module with the name "ThisWorkbook1".

How to directly import the "ThisWorkbook" into the original/true
"ThisWorkbook" class-module, without having to copy and paste the imported
code?
 
D

Dave Peterson

The ThisWorkbook class module can't be imported/deleted.

But you can add procedures into it.

Check Chip Pearson's site:
http://www.cpearson.com/excel/vbe.aspx
look for: Creating An Event Procedure

==========
Another option that may be easier if you're creating a new workbook...

Create a template file (*.xlt). Put all the code you need in that template's
project--including all the events you want in the ThisWorkbook module.

Then use that file as the template for the new workbook.

Dim NewWkbk as workbook
set newwkbk = workbooks.add(Template:="C:\yourpath\myfile.xlt")
 
B

Bob Phillips

You have to remove the original first, otherwise you get the situation that
you describe.
 

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