Fibioспасибо, ступил, все работает
переменная text8 - нигде не определена а вы ее в search_replace передаете
def search_replace(file, find_str, replace_str):
app.Documents.Open(file)
app.Selection.Find.Text = find_str
found=app.Selection.Find.Execute()
doc=app.ActiveDocument
if found:
app.Selection.TypeText(replace_str)
doc.SaveAs(os.getcwd()+'\\pension.doc')
else:
doc.Close(SaveChanges=False)
return found
f= 'C:\\1.doc'
search_replace(f, 'text1', text1)
search_replace(f, 'text8', text8)
search_replace(f,'text9', text9)
app.Application.Quit(-1)
Fibioспасибо, ступил, все работает
переменная text8 - нигде не определена а вы ее в search_replace передаете
def search_replace(file, find_str, replace_str):
app.Documents.Open(file)
app.Selection.Find.Text = find_str
found=app.Selection.Find.Execute()
doc=app.ActiveDocument
if found:
app.Selection.TypeText(replace_str)
doc.SaveAs(os.getcwd()+'\\pension.doc')
else:
doc.Close(SaveChanges=False)
return found
f= 'C:\\1.doc'
search_replace(f, 'text1', text1)
search_replace(f, 'text8', text8)
search_replace(f,'text9', text9)
app.Application.Quit(-1)