ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to import events VBA code in Excel? (https://www.excelbanter.com/excel-programming/443645-how-import-events-vba-code-excel.html)

JYH

How to import events VBA code in Excel?
 
Good day everyone,

I have a small fleet of Excel apps who, sometime, need updating.
For modules, I simply
ThisWorkbook.VBProject.VBComponents("WhateverModul e").Export
tempFile
DestWbk.VBProject.VBComponents.Import tempFile
Kill (tempFile)

But I can not use the same code to import into ThisWorkbook as I do
for modules.
ThisWorkbook.VBProject.VBComponents("ThisWorkbook" ).Export
tempFile
DestWbk.VBProject.VBComponents.Import tempFile
Kill (tempFile)

Instead of replacing (or adding) the code within ThisWorkbook, it
creates a new Class Modules named "ThisWorkbook1".

Do you have any suggestion on how could I fix that?

The only other solution is to manually set all my events to something
static refering to a module.

Thank you


Per Jessen[_2_]

How to import events VBA code in Excel?
 
Hello,

Look at Chip Pearson's site:

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

The section "Copy A Module From One Project To Another" should solve
your problem.

Regards,
Per

On 23 Sep., 20:37, JYH wrote:
Good day everyone,

I have a small fleet of Excel apps who, sometime, need updating.
For modules, I simply
* * ThisWorkbook.VBProject.VBComponents("WhateverModul e").Export
tempFile
* * DestWbk.VBProject.VBComponents.Import tempFile
* * Kill (tempFile)

But I can not use the same code to import into ThisWorkbook as I do
for modules.
* * ThisWorkbook.VBProject.VBComponents("ThisWorkbook" ).Export
tempFile
* * DestWbk.VBProject.VBComponents.Import tempFile
* * Kill (tempFile)

Instead of replacing (or adding) the code within ThisWorkbook, it
creates a new Class Modules named "ThisWorkbook1".

Do you have any suggestion on how could I fix that?

The only other solution is to manually set all my events to something
static refering to a module.

Thank you



JYH

How to import events VBA code in Excel?
 
Thank you very much.

I am not sure why my code wasn't working but I'll use his code until I
can figure out why.

Thank you again very much


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com