Consulting

Results 1 to 2 of 2

Thread: Code to delete all modules

  1. #1

    Code to delete all modules

    hi everybody
    Sorry about the bad english...

    I need a code to delete all modules.

    Example, i have 20 workbooks, then i want delete all modules that exists in thats workbooks , so i want a code to do this for me. It is possible? I think is not, i tried several times but ?ot solve the question...

    thanks....

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    '----------------------------------------------------------------
    Sub DeleteModules()
    '----------------------------------------------------------------
    Dim oVBMod As Object
    Dim i As Long

    With ActiveWorkbook.VBProject
    For Each oVBMod In .vbcomponents
    Select Case oVBMod.Type
    Case 1: 'vbext_ct_StdModule
    ActiveWorkbook.VBProject.vbcomponents.Remove oVBMod
    End Select
    Next oVBMod
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •