Jump to content

Replace in Word


Recommended Posts

$Word = ObjCreat("Word.Application")
$Word.Documents.Open(@ScriptDir & "\Vorlagen\Mahnung.doc")
With $Word.Selection.Find
   .ClearFormatting
   .Replacement.ClearFormatting
   .Text = "%Ort%"
   .Replacement.Text = "Bad Blankenburg"
   .Forward = 1
   .Wrap = 1
   .Format = 0
   .MatchCase = 0
   .MatchWholeWord = 0
   .MatchWildcards = 0
   .MatchSoundsLike = 0
   .MatchAllWordForms = 0
   .Execute Replace: = 2
EndWith
$Word.Activedocument.Save()
$Word.Activedocument.Close

In Zeile 16 nimmt AutoIt Replace: = 2 nicht an und in " " wird es von Word nicht angenommen.

or:

In line 16 AutoIt not take Replace: = 2 and in " " it is not accepted by Word.

Edited by Ahnungslos
Link to comment
Share on other sites

In line 16 AutoIt not take Replace: = 2 and in " " it is not accepted by Word.

Try: .Execute(Replace=2)

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Hi,

This works on my machine;

;replacedoc.au3
;replacedoc.doc
$Word = ObjCreate("Word.Application")
$Word.Documents.Open(@ScriptDir & "\replacedoc mydoc.doc")
With $Word.Selection.Find
   .ClearFormatting
   .Replacement.ClearFormatting
;~    expression.Execute(FindText, MatchCase, MatchWholeWord, MatchWildcards, &_
;~ MatchSoundsLike, MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace,&_
;~ MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl)
   .Execute("aaa", false, false, false, false, false, true, false, false, "bbb", 2)
EndWith
MsgBox(0,"","")
$Word.Activedocument.Save()
$Word.Activedocument.Close
$Word.quit
$Word=""
Best, Randall
Link to comment
Share on other sites

Hi,

never thought of using something like that, but I was interested and tested it. I noticed that the winword.exe doesn't close after the script has finished.

Is that normal?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...