Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2004, 12:35 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default Removal of modules

Hi
I can remove lines in CodeModule by using the following syntax

For I = 1 To 3
Application.VBE.SelectedVBComponent.CodeModule .DeleteLines (1), 1
Next

But actually I would like to remove the whole module, does anyone know how to do this, if posssible ?

Cheers
Karsten

I found the solution. If anyone else is interested.
set a reference to:
Microsoft Visual Basic for Application Extensibility.

And use the following code in a module.
Sub DeleteModule()
  Dim VBComp As VBComponent
  Set VBComp = ThisWorkbook.VBProject.VBComponents("Module2")

  ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

Cheers





Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic history removal ermy78 SQL Server 2005 0 February 18th, 2008 02:41 PM
namespace removal manish_jaiswal XSLT 5 February 15th, 2008 05:40 AM
Close button removal canuck38 Access 4 July 16th, 2004 03:50 AM
Chapt 6 Removal from an ArrayList Jerry Obrien BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 February 19th, 2004 02:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.