Updating toc in word using Python

Hi again,

I’d like to ask a question about modifying/updating the table of contents (toc) in word using python, and if it complies with VIKTOR. Previously, we ran into a problem that certain code windows environment, but not in Linux, such as the code snippet below. Will it work on VIKTOR platform when the app is published?

Thanks in advance! :pray:

def update_toc(file_path_to_docx: str):
    # TODO: package win32com does not exist in linux. Fix for Linux is yet to found
    word = win32com.client.DispatchEx("Word.Application")
    doc = word.Documents.Open(file_path_to_docx)
    doc.TablesOfContents(1).Update()
    doc.Close(SaveChanges=True)
    word.Quit()

Hey Yida,

Unfortunately, the apps you publish on the VIKTOR platform will run on Linux. As a dev, to get the closest reproduction of the published app, you can use the advanced installation (using WSL and docker).

You can find more information about the possible differences between your developement and the published app here

1 Like