The Wayback Machine - https://web.archive.org/web/20230129152323/https://github.com/python-openxml/python-docx/issues/1156
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make hyperlink at exist string? #1156

Open
emadyounan opened this issue Nov 15, 2022 · 0 comments
Open

how to make hyperlink at exist string? #1156

emadyounan opened this issue Nov 15, 2022 · 0 comments

Comments

@emadyounan
Copy link

Good evening,

I have two document files and I need to make the first document file hyperlink to the other one from the text I extracted from the table cell

wordDoc = Document(r'testfile.docx')

for table in wordDoc.tables:
    for row in table.rows:
        for cell in row.cells:
            if cell.text == "page" or cell.text == "subject":
                pass
            else:
                if cell.text.isdigit():
                   # i need to add hyperlink to this cell text to that file
                   # cell text will be like 3
                    add_hyperlink(cell.text, "test2.docx#3")
                    wordDoc.save('demo.docx')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant