• Macro to Remove Macros (2000/SP3)

    Author
    Topic
    #441457

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1060098

      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.

      • #1060166

        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.

      • #1060183

        Thank you for this one Hans.

    Viewing 0 reply threads
    Reply To: Macro to Remove Macros (2000/SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: