ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove and Import Module (https://www.excelbanter.com/excel-programming/339007-remove-import-module.html)

Richard

Remove and Import Module
 
I need to replace a module in selected workbooks with a module having the
same name.

I'm using the Remove method of the VBComponents collection to remove the
module.

I'm also using the Import method to import a module from a *.bas file.

The problem is:

....the module isn't 'removed' immediately following processing of the Remove
method, therefore, since a module with the same name still exists,

....when the Import processes, the new module is given the name with a '1' at
the end

....when processes ends...the 'removed' module is finally 'removed'

Is there a way to complete the Remove prior to the Import so that the
imported module will not have the '1' in the name?

Thanks,

--
Richard

Michael Beckinsale

Remove and Import Module
 
Richard,

Pls see my post of yesterday which contains code which does exactly as you
describe and which works fine.

Only problem l can envisage without seeing your code is that my code is
contained in a "control" type of workbook which is independent from the
workbook which needs modifying. If you try and run the code in the workbook
which needs modifying you will have problems which l believe is caused by
the way the project is compiled.

Chip Pearson has some great coding / tips about this on his website

www.cpearson.com

Regards

Michael Beckinsale


"Richard" wrote in message
...
I need to replace a module in selected workbooks with a module having the
same name.

I'm using the Remove method of the VBComponents collection to remove the
module.

I'm also using the Import method to import a module from a *.bas file.

The problem is:

...the module isn't 'removed' immediately following processing of the
Remove
method, therefore, since a module with the same name still exists,

...when the Import processes, the new module is given the name with a '1'
at
the end

...when processes ends...the 'removed' module is finally 'removed'

Is there a way to complete the Remove prior to the Import so that the
imported module will not have the '1' in the name?

Thanks,

--
Richard





All times are GMT +1. The time now is 01:21 PM.

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