Is there a way to link from one part of document to another part of the same document using python-docx?

My objective is to list out the various contents of a document in a tabular format and then link the text to the locations they are referring to. It is similar to the navigation pane of MS Word in which the various headings can be seen and can jump from one location to another using the links.

Is there any way in which I can link one part of the document to another such that when you click the link you jump to the location?

I am trying to code in this format.

head = document.add_heading('aaa', level=1) add_to_table(document, head) 

Pass this heading to another function which would add to the heading to a table.

def add_to_table(document, heading):     table = document.tables[0]     cells = table.add_row().cells     cells[0].text = heading.text     add_hyperlink(cells[0], heading) 

I am not sure if there is any function like add_hyperlink as I have written above. Is there any way this can be accomplished?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.