Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Deleting a macro using a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas - 13 Nov 2007 00:23 GMT
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?
OssieMac - 13 Nov 2007 00:44 GMT
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

> Hi,
>
[quoted text clipped - 5 lines]
> is opened. Unfortunately, I haven't a clue how to delete this automatic macro
> and not the other. Can you help me on this?
OssieMac - 13 Nov 2007 00:50 GMT
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

> Hi,
>
[quoted text clipped - 5 lines]
> is opened. Unfortunately, I haven't a clue how to delete this automatic macro
> and not the other. Can you help me on this?
JMB - 13 Nov 2007 03:38 GMT
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.

> Hi,
>
[quoted text clipped - 5 lines]
> is opened. Unfortunately, I haven't a clue how to delete this automatic macro
> and not the other. Can you help me on this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.