For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > September 2004 > Find text in Word document









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Find text in Word document
Woolf

2004-09-28, 3:55 pm

Hi all,
I try to find keywords in a Word document without opening the doc.
I use the following code

Open sFile For Binary As iFile
sBuffer = Space$(LOF(iFile))
Get #iFile, , sBuffer
Close iFile

Then I search with
If InStr(1, sBuffer, sKeys(j), vbTextCompare) > 0 Then ...

However there are some keywords I cannot find unless I do
sBuffer = StrConv(sBuffer, vbFromUnicode)
others I can only find if there is no conversion of the text

My workaround now is
sTemp = sBuffer
' Convert
sBuffer = StrConv(sBuffer, vbFromUnicode)
' Put together
sBuffer = sBuffer & sTemp

Is this the only way to do the search or am I missing something here
Thanks
Woolf



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com