Open DanyaalMajid opened 5 months ago
Hi, This might help you
from docx import Document from docx.enum.style import WD_STYLE_TYPE
dest_doc = Document(dest_file)
followed_hyperlink_style = None for style in dest_doc.styles: if style.name.lower() == "followedhyperlink": followed_hyperlink_style = style break
if not followed_hyperlink_style: print("Creating Followed Hyperlink style...") followed_hyperlink_style = dest_doc.styles.add_style( "FollowedHyperlink", WD_STYLE_TYPE.CHARACTER )
followed_hyperlink_style.font.color.rgb = RGBColor(20, 57, 111)
I have been facing this peculiar issue, i need to change the color of the FollowedHyperlink style to something else, but it cant be found in some documents, even though all the documents were created by python-docx from the start.
If i try to manually create the style if its not found, it shows up as "FollowedHyperlink1" and does not change the color of the "Followed Hyperlink".
The code i have been using is below:
Please help fix this, all documents being processed were created from scratch by python-docx. Also the FollowedHyperlink style in the unmodified docx is actually called "Followed Hyperlink (Hide Until Used)", but its the same case in even the documents for which the style is found, so i dont think the Hide Until Used thing is an issue.