How to display and change SensitivityLabel for a Word document (desktop)?

Viewed 46

I would like to know the sensitivity label of my current Word file, change it with a new value and save my file

I start by opening a Word file

    # Opening a MS Word file in pywin32
    from win32com.client import Dispatch
    myWord = Dispatch('Word.Application')
    myWord.Visible = 1
    myWord.Documents.Open("C:/./TEMP.docx")  # open file

    # SetLabel and GetLabel
    print(myWord.ActiveDocument.SensitivityLabel)
    print(myWord.ActiveDocument.SensitivityLabel.SetLabel)
    print(myWord.ActiveDocument.SensitivityLabel.GetLabel())

    # Create label info
    myLabelInfoNew = myWord.ActiveDocument.SensitivityLabel.CreateLabelInfo()

    # Close Word Application
    myWord.ActiveDocument.SaveAs("C:/./TEMP2.docx")
    myWord.Quit()

How can I fix it?

Thank you for your help

0 Answers
Related