Results 1 to 2 of 2
  1. #1
    dweller
    Guest

    "Macro" Property In Word 2000 Document (English / VB / 6.0)

    I would like to scan a large set of Word documents and list only those that have embedded macros. I have not been able to find any document property that would give this information.

    Is there a way to programmatically determine the presence or absence of a macro in a Word document ?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: "Macro" Property In Word 2000 Document (English / VB / 6.0)

    Perhaps you can do this by detecting whether the document contains a code module (either a standard module, form, or class module)?

    Sub FindVBComponents()
    Dim aVBComp As Object
    For Each aVBComp In ActiveDocument.VBProject.VBComponents
    If aVBComp.Type < 100 Then 'not just ThisDocument
    MsgBox aVBComp.Name & " is type " & aVBComp.Type
    End If
    Next
    End Sub

    Or maybe a function is better for your needs?

    Sub TestFunc()
    MsgBox bolContainsAModule(ActiveDocument)
    End Sub

    Function bolContainsAModule(docDocument As Document) As Boolean
    bolContainsAModule = False
    Dim aVBComp As Object
    For Each aVBComp In docDocument.VBProject.VBComponents
    If aVBComp.Type < 100 Then 'not just ThisDocument
    bolContainsAModule = True
    End If
    Next
    End Function

    I think there were previous postings on how to find out the actual names of procedures and such. If you need that level of detail, you should use the Lounge Search engine.

Posting Permissions

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