I was wondering if this is even possible. I have some knowledge of
Visual basic. I want to search a computer for certian files such as
excel, word, and text documents. I then want to open the file and make
sure they do not have any phone numbers in these files. Is this
something that is possible to do? Thank you for any help you can give.
I can think of 2 options
Option 1 - Don't use VB!
I would suggest using a program like Grep
(
http://www.gnu.org/software/grep/grep.html).
then you could do a command line search for those files, specifying a
regular expression that will match a phone number ([0-9]{5} [0-9]{6}
would be a basic suggestion).
However, as Word and Excel files are binary files (for versions of
Office prior to 2007), it is unlikely grep would be able to find a match.
I think there are other programs which will index files on your
hard-drive (Google do one), but I don't know what their reg-ex
capabilities are.
Option 2 - VB Program:
A (very simple) psuedo code solution might look vaguely like :
Function FindPhoneNumber (sFolder as String)
For Each folder in sFolder
FindPhoneNumber (sFolder)
Next
For Each file in sFolder
If IsTextFile(file) Then
'Read in the text file and
'perform a reg-ex match on it
'If found, add file to some global list of files.
ElseIf IsWordFile (file) Then
'Use the Word API to perform a search
'If found, add file to some global list of files.
ElseIf IsExcelFile (file) Then
'Use the Excel API to perform a search
'If found, add file to some global list of files.
End If
Next
End Function
Note that using the Word and Excel API's is not entirely
straightforward, and I'm not sure what their regex capabilities are (I
know you can use wildcards in Word searches, but I'm not sure
Hope that helps - if you explain more thoroughly what you hope to
achieve, might be able to help a bit more
Cheers,
RB.