Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default 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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default 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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Deleting A Macro Using VB.NET Elena Excel Programming 2 June 5th 06 08:29 PM
Deleting Row Macro Steve M Excel Worksheet Functions 4 April 20th 06 03:42 PM
deleting row using macro need help excelguru Excel Programming 2 August 17th 04 10:59 PM
Deleting macro Stephane[_3_] Excel Programming 3 May 4th 04 06:12 PM


All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"