Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Macro for searching Word macros 2

Status
Not open for further replies.

rjasper

Programmer
Apr 5, 2001
6
0
0
US
I need to write a macro that will open all .docs in a directory and then search for a text string. I don't want to search the document however, I want to search the attached macros themselves. I can figure out the opening of the documents in a directory but I have no idea where to even start to do a find in a macro through macro code. Any help would be appreciated.

Thanks
 
I too have run into this issue, if anyone could help it would be appreciated.

Thanks.
 
should get you started
(you'll need to add a reference to 'Microsoft Visual Basic for Applications Extensibility')

Code:
Option Explicit

Sub test()
  MsgBox "test"
End Sub

Sub test2()
  Dim VBC As VBComponent
  
  For Each VBC In ActiveDocument.VBProject.VBComponents
    If VBC.CodeModule.Find("MsgBox ""test""", 0, 0, VBC.CodeModule.CountOfLines, 255) Then
      MsgBox "found"
    End If
  Next VBC
End Sub
 
I have a CodeSearch macro that performs a text search of code modules behind Word templates and docs. Email me at SlavaIngman@bswip.com.au and I will gladly send it to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top