Editing text in a ChemDraw OLE in Word

Viewed 13

StackOverflow!

I'm trying to write a Python program to replace text in a ChemDraw OLE present in a Word document. For example I want the program to replace "num" in the below OLE with "1" (see picture)

I've tried to write such program, but it only replaces text in the Word file, but doesn't change anything in the OLE:

import win32com.client
f = 'C:/Users/Adrian/Desktop/asdasdas.docx'
app = win32com.client.DispatchEx("Word.Application")
app.Visible = False
app.DisplayAlerts = False
app.Documents.Open(f)
app.Selection.Find.Execute("num", False, False, False, False, False, True, wdFindContinue, False, "1", wdReplaceAll)
app.ActiveDocument.Close(SaveChanges=True)
app.Quit()

Any help on how to edit OLE would be appretiated. The word file with the OLE is available here.

0 Answers
Related