Jump to content

Search for text in an existing word document


Recommended Posts

It can be a little ambiguous - here it is how to do it:

$oWord = _WordCreate("my file with full path", 0, 0) ;hidden
If _WordDocFindReplace($oWord, "my text") Then
    MsgBox(0, "found", "text found")
Else
    MsgBox(0, "not found", "text not found")
EndIf
_WordQuit($oWord)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Straight from the help file - you should read that by the way.

*******************************************************
; Example 1 - Create a word window, open a document, find "this", 
;               replace all occurrences with "THIS", quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oFind = _WordDocFindReplace($oDoc, "this", "THIS")
If $oFind Then
    MsgBox(0, "FindReplace", "Found and replaced.")
Else
    MsgBox(0, "FindReplace", "Not Found")
EndIf
_WordQuit ($oWordApp, 0)

It looks like my first example wasn't working.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...