Batch-Text-Replacement
Command Description
Replace a specific string in a Word document
Command Prototype
bRet = Word.Replace(objWord,sFind,sReplace,optionArgs)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objWord | True | expression | objWord | Word document object |
sFind | True | string | "" | The string to match |
sReplace | True | string | "" | The string to replace |
matchCase | None | boolean | None | Whether to be case sensitive; the default is case-insensitive |
matchWholeWord | None | boolean | None | Whether to match whole word only, the default is "no" |
matchWildcards | None | boolean | None | Whether to support wildcard (the default is not to support wildcard) |
forward | None | boolean | True | Whether to find down/forward, the default is "yes" |
wrap | None | enum | 0 | The method for loop matching after a matching is completed |
replaceType | None | enum | 1 | The method for replacing the content |
return
bRet,The variable used to save the output of the command.
Demo
/************************************Text batch replacement************* ****************************
Command prototype:
Word.Replace(objWord,sFind,sReplace,optionArgs)
Input parameters:
objWord--Word document object
sFind--string to match
sReplace--the string to be replaced
matchCase--is case sensitive
matchWholeWord--is case sensitive
matchWildcards--Whether wildcards are supported
forward--whether to look down/backward
wrap--After matching, the way of loop matching
replaceType--the way to replace the content
Outgoing reference:
bRet -- The result returned after the command is run
*********************************************************************************/
Dim objWord , bRet
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
bRet = Word.Replace(objWord,"表","biao",{"matchCase":false,"matchWholeWord":false,"matchWildcards":false,"forward":true,"wrap":2,"replaceType":"1"})
TracePrint ($ PrevResult)