![]() |
Deleting a macro using a macro
Hi,
I have created a templete with a 2 macros in it. The first is a macro that will be needed within new book which will be created from the template. The second is an automatic macro designed to set up the book and (hopefully) delete itself from the book (the macro can't be deleted from the template for it will be needed the next time the template is used) as soon as the template is opened. Unfortunately, I haven't a clue how to delete this automatic macro and not the other. Can you help me on this? |
Deleting a macro using a macro
Hi Thomas,
Create the new workbook from a macro in the template. You can record the macro for creating the new workbook to get the syntax. After you create the new workbook, you can copy the worksheets from your template to the new workbook. When copying the worksheets, use the method of right click on the tab with the worksheet name and select Move or copy. (Record this also to get the syntax for the macro) There will be no macro in the new workbook to delete. Regards, OssieMac "Thomas" wrote: Hi, I have created a templete with a 2 macros in it. The first is a macro that will be needed within new book which will be created from the template. The second is an automatic macro designed to set up the book and (hopefully) delete itself from the book (the macro can't be deleted from the template for it will be needed the next time the template is used) as soon as the template is opened. Unfortunately, I haven't a clue how to delete this automatic macro and not the other. Can you help me on this? |
Deleting a macro using a macro
Hi again Thomas,
My apologies. I did not read your question properly and you want to keep one of the macros in the new workbook. To do this, use a separate workbook with the macro to to create the new workbook. The macro which is to remain can be in the template. Regards, OssieMac "Thomas" wrote: Hi, I have created a templete with a 2 macros in it. The first is a macro that will be needed within new book which will be created from the template. The second is an automatic macro designed to set up the book and (hopefully) delete itself from the book (the macro can't be deleted from the template for it will be needed the next time the template is used) as soon as the template is opened. Unfortunately, I haven't a clue how to delete this automatic macro and not the other. Can you help me on this? |
Deleting a macro using a macro
perhaps something similar to:
Private Sub Test() On Error Resume Next With Workbooks("WorkbookName").VBProject.VBComponents(" ModuleName").CodeModule .DeleteLines startline:=.ProcStartLine("ProcedureName", 0), _ Count:=.ProcCountLines("ProcedureName", 0) End With End Sub watch for wordwrap caused by the newsgroup. "Thomas" wrote: Hi, I have created a templete with a 2 macros in it. The first is a macro that will be needed within new book which will be created from the template. The second is an automatic macro designed to set up the book and (hopefully) delete itself from the book (the macro can't be deleted from the template for it will be needed the next time the template is used) as soon as the template is opened. Unfortunately, I haven't a clue how to delete this automatic macro and not the other. Can you help me on this? |
All times are GMT +1. The time now is 02:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com