|
-
Jan 5th, 2009, 09:24 PM
#29
Re: Is this word in this Word 2007 document ?
once opened for binary, you can also read the file using input or line input
depending on the size of your files i would just read entire file into a single string, then use instr to find if your search string was included in the file
vb Code:
open "Somefile.doc" for binary as 1 mystr = input(lof(1),#1) close 1 pos = instr(1, mystr, searchstr, vbtextcompare) if pos > 0 then msgbox "found in this file"
i know thiswill work in text files containing end of file characters, and i have tested with word doc, but i can not promise that it will always find the correct answers
this being the case, the same code will work as you use for text files, except open for binary
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|