Dear, I have a question
I want to search text by style not by content. for example, I want to find all superscript text in docment, and add some special char before and next them?
like (in latex style) this:
A^{123} -> A^{&123&}
B^{456} -> B^{&456&}
all superscript are different. So how can I do this in python? Thanks
@ZZZ21321 You can use Font.superscript property to detect whether some run of text is superscripted. For example see the following code:
doc = aw.Document("C:\\Temp\\in.docx")
# get all run nodes in the document.
runs = doc.get_child_nodes(aw.NodeType.RUN, True)
# loop through all runs and modify superscripted runs
for r in runs :
run = r.as_run()
if run.font.superscript :
run.text = "&" + run.text + "&";
# save the outtput
doc.save("C:\\Temp\\out.docx")