PC Review


Reply
Thread Tools Rate Thread

Deleting a macro using a macro

 
 
=?Utf-8?B?VGhvbWFz?=
Guest
Posts: n/a
 
      13th Nov 2007
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 With Quote
 
 
 
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      13th Nov 2007
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?
>

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      13th Nov 2007
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?
>

 
Reply With Quote
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      13th Nov 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting code from a macro (by a macro) =?Utf-8?B?QnJldHRqZw==?= Microsoft Excel Misc 2 8th May 2007 10:14 PM
MACRO for Deleting every 2nd ROW =?Utf-8?B?VHVmYWls?= Microsoft Excel Programming 1 18th Jun 2006 04:04 PM
Deleting A Macro Using VB.NET =?Utf-8?B?RWxlbmE=?= Microsoft Excel Programming 2 5th Jun 2006 08:29 PM
Deleting a macro? MTC Microsoft Excel Misc 2 31st Aug 2004 07:38 PM
deleting a row with macro clayton Microsoft Excel Misc 3 15th Jan 2004 03:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:14 AM.