Consulting

Results 1 to 3 of 3

Thread: Remove module from closed workbook

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Location
    Aalst - Belgium
    Posts
    14
    Location

    Remove module from closed workbook

    is it possible to remove modules from a closed workbook ?
    I've a lot of workbooks where i want to remove a module.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Just must open each workbook.

    You can have a macro open each workbook in a folder, delete the module, then save and close the workbook.

    Are the projects in these workbooks password protected?
    What is the module that you want to remove?

  3. #3
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    Small sample you could use:

    Sub DeleteCodeModule()
     With Application
        .ScreenUpdating = False
    .Workbooks.Open ("C:\index.xls")
        With .ActiveWorkbook
            .VBProject.VBComponents.Remove .VBProject.VBComponents("Module2")
            .Save
            .Close
        End With
    .ScreenUpdating = True
     End With
    End Sub

    In 2000 this will run without problems in version greater then 2000 you need to check "Trust access to vbproject" on the second tab of macro security settings.

    Otherwise it won't allow you to perform this action to the VBE.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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