Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Macro to Remove Macros (2000/SP3)

    I've got 100+ documents based on one template and each document looks to that template; however, all of the documents include the macros that are in the template instead of just looking to the template.

    I know I can remove the document macros through the organizer window and I tried to record a macro to do so, but the macro looks to the specific document which won't work for the other docs. Can the following macro be modified to look at "active document" or something similar so it will work for all of docs?

    Sub Masters()
    '
    ' Masters Macro'
    Application.OrganizerDelete Source:="C:temp23 84 16.doc", Name:= _
    "MasterSpec", Object:=wdOrganizerObjectProjectItems
    Application.OrganizerDelete Source:="C:temp23 84 16.doc", Name:= _
    "NewMacros", Object:=wdOrganizerObjectProjectItems
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=Chr(11) & Chr(11)
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.HomeKey Unit:=wdStory
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Remove Macros (2000/SP3)

    You could use this code if you want to remove modules from the active document:

    Sub RemoveModules()
    With ActiveDocument.VBProject.VBComponents
    .Remove .Item("MasterSpec")
    .Remove .Item("NewMacros")
    End With
    End Sub

    If you place all these documents in one folder, you could create a macro that loops through the documents and removes the modules from each in turn.

    BTW, if macros get included in the document if you create a new document from a template, it is probably not a real template but a document renamed to .dot.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to Remove Macros (2000/SP3)

    Thanks Hans, works perfectly.

    I'm not sure how the person got all macros in the doc. I was able to do it, but it was a time-consuming mess with many steps involved, and can't imagine anyone doing it. I was also able to copy the macros through the organizer from the template to the document and I'm leaning more toward the latter that this is how it happened.

    Anyhow, thanks much - I can move along more swiftly now.

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to Remove Macros (2000/SP3)

    Thank you for this one Hans.
    Regards
    Don

Posting Permissions

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