5
win32com.client Pythonライブラリを検索して置き換えて複数の文字列値をWord文書に追加しようとしています。pythonでwin32com.clientを使用する方法複数のテキストを見つけて置き換える方法
私は1つの値を見つけて置き換えることができますが、複数の値に対してこれを行う方法はわかりません。
これは私がこれまで持っているものです。
import win32com.client
word = win32com.client.DispatchEx("Word.Application")
word.Visible = True
word.DisplayAlerts = 0
word.Documents.Open("C:\TEMP\Testing\Me.docx")
word.Selection.Find
find.Text = "First Name"
find.Replacement.Text = "John"
find.Execute(Replace=1, Forward=True)
# the following part doesn't run
find.Text = "Last Name"
find.Replacement.Text = "Smith"
find.Execute(Replace=1, Forward=True)
word.ActiveDocument.SaveAs('C:\TEMP\Testing\Me2.docx')
word.Quit() # releases Word object from memory
任意の提案ですか?