Link to home
Start Free TrialLog in
Avatar of Tmess
TmessFlag for United States of America

asked on

Search *.Docs for Macros

Does anyone know how to search a word document for macros? I know how to search a document for specific words, headings, ect. But how does one actually search for code behind the document?

Our company does not use Word frontends and programmers are not supposed to develop in word. We have been having problems with viruses disguised as word documents and templates. All employees have been told hold to enable the word macro warning but as many of you know, the chain is only as strong as its weakest link. Also we have on every computer McAffee Virus scan. It is also supposed to be updated regularly by the user.

I know where to search for a word virus macro but that is not enough. I need to know what files have been infected which in my case would be *any* document with a macro.

Any  help would be appreciated.
Avatar of sduckett
sduckett

This would narrow your list down:
Start|Find|Files or Folders
Named: *.do?
Containing Text: Auto

This is using the assumption that all macro viruses use an AUTO-macro and obviously there would be a few false alarms. To reduce the false alarms you could spell out Auto_Open and Auto_Close etc.

(There's probably a better way)
Good Luck
Avatar of Tmess

ASKER

sduckett,

I took what you said and I ran it from an access db. However, when it does the search, it only looks for words that are contained in the document and not in the code behind the document. This is the code I used. It's rather crude but I'm just trying to get it right first.

 Any more suggestions?

Dim db As Database
Dim fs As Object, i As integer, strItems As String


Set db = CurrentDb: Set fs = Application.FileSearch

With fs
    .lookin = "D:\"
    .filename = "*.doc"
    .SearchSubFolders = True
    .TextOrProperty = "Auto*'Find Word doc(s) contatining this text
     
        If .Execute > 0 Then
                For i = 1 To .foundfiles.Count
                   strItems = .foundfiles(i)
                 MsgBox "these are them" & " " & strItems
                Next
        End If

End With
set db = nothing
set fs = nothing
end sub
Access doesn't use the same search engine.
It's a pretty good ad hoc method, using the Find on the Start-Menu.
If you're doing a system clean-up then it is a pretty good method.
If you're trying to write some kind of virus scanner then don't go near it with a long pole.
BTW if you go in as a user who has read rights to all parts of the system and you map a drive letter to the root of each workstation you only have to set the search off once, looking in 'My Computer'. Just do it before you go to lunch.
Avatar of Tmess

ASKER

Sduckett, thanks for the comments.

Sorry it took so long to respond. Please answer the question. I am satisfied with your comments

Tmess
ASKER CERTIFIED SOLUTION
Avatar of sduckett
sduckett

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tmess

ASKER

Thanks