ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Importing a macro programatically (https://www.excelbanter.com/excel-programming/341245-importing-macro-programatically.html)

[email protected]

Importing a macro programatically
 
I have a conundrum. My application loads a csv file into excel and does
some bits and bobs to it. In doing so it imports a macro from a text
file runs the code and exports it again That works fine. However it
does this before displaying the data sheet.

What I want to do is to import some code which will remain active and
allow the user to interact once it is loaded. I also import a worksheet
as a summary page during the process and have tried importing a macro
with this. This imports but the scope of the macro is such that I
cannot use it to manipulate another sheet.

If I use an add-in I would need to reference the addin in teh
workbook. The workbook is created new each time and so this wouldn't
work. Can I make a macro in a worksheet become public?

COuld I move it programatically to the other sheet I need to use it in?
The application cunningly removes all extraneous modules added as it is
working so even if I could add a new module it would get removed.

Could I add a procedure to the existing module? It is a complex issue
and I hope I have made it clear. I am limited by the way the
application works and cannot re-write that as it would upset everything
else!
John Robinson


Jim Thomlinson[_4_]

Importing a macro programatically
 
Give this site a look...

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

It might be just the ticket.
--
HTH...

Jim Thomlinson


" wrote:

I have a conundrum. My application loads a csv file into excel and does
some bits and bobs to it. In doing so it imports a macro from a text
file runs the code and exports it again That works fine. However it
does this before displaying the data sheet.

What I want to do is to import some code which will remain active and
allow the user to interact once it is loaded. I also import a worksheet
as a summary page during the process and have tried importing a macro
with this. This imports but the scope of the macro is such that I
cannot use it to manipulate another sheet.

If I use an add-in I would need to reference the addin in teh
workbook. The workbook is created new each time and so this wouldn't
work. Can I make a macro in a worksheet become public?

COuld I move it programatically to the other sheet I need to use it in?
The application cunningly removes all extraneous modules added as it is
working so even if I could add a new module it would get removed.

Could I add a procedure to the existing module? It is a complex issue
and I hope I have made it clear. I am limited by the way the
application works and cannot re-write that as it would upset everything
else!
John Robinson




All times are GMT +1. The time now is 05:23 PM.

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