ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Transfer control to new module in macro (https://www.excelbanter.com/excel-programming/277713-transfer-control-new-module-macro.html)

BrianG[_4_]

Transfer control to new module in macro
 
I need to delete all macros and vbComponents on save. I'm able to
perform all the vb Component deletions but I can't figure out how to
transfer control to a new module that deletes all other modules. All is
well when I execute the Delete_Macros module by itself but my attempts
at transferring control to it from the Delete_vbComponents module result
in the calling module not being deleted. What am I missing?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

jaf

Transfer control to new module in macro
 
Hi Brian,
You can't delete the code module that the code is running in no matter where
it is.

A possible solution would be to open another workbook.
Use application.run to run a code module in wb2 that deletes the modules in
wb1 and then closes.


--

John

johnf202 at hotmail dot com


"BrianG" wrote in message
...
I need to delete all macros and vbComponents on save. I'm able to
perform all the vb Component deletions but I can't figure out how to
transfer control to a new module that deletes all other modules. All is
well when I execute the Delete_Macros module by itself but my attempts
at transferring control to it from the Delete_vbComponents module result
in the calling module not being deleted. What am I missing?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




BrianG[_3_]

Transfer control to new module in macro
 
"jaf" wrote in message
You can't delete the code module that the code is running in no matter where
it is.


I have my Auto_Open sub in Module1. I then call a Sub in Module2 to
delete Module1. If I run the Sub by itself, Module1 gets deleted but
if let Module1 call the Sub in Module2, Module1 does not get deleted.
I need to automatically delete the Auto_Open sub so that it doesn't
run on subsequent opens.

If I can't cut the ties to Module1 so that it can be deleted by a Sub
in Module2, is opening another workbook the only way?

BrianG

"jaf" wrote in message ...
Hi Brian,
You can't delete the code module that the code is running in no matter where
it is.

A possible solution would be to open another workbook.
Use application.run to run a code module in wb2 that deletes the modules in
wb1 and then closes.


--

John

johnf202 at hotmail dot com


"BrianG" wrote in message
...
I need to delete all macros and vbComponents on save. I'm able to
perform all the vb Component deletions but I can't figure out how to
transfer control to a new module that deletes all other modules. All is
well when I execute the Delete_Macros module by itself but my attempts
at transferring control to it from the Delete_vbComponents module result
in the calling module not being deleted. What am I missing?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



All times are GMT +1. The time now is 05:10 AM.

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