【发布时间】:2022-11-03 02:06:35
【问题描述】:
我想知道我当前 Word 文件的敏感度标签,用新值更改它并保存我的文件
我首先打开一个 Word 文件
# 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()
我该如何解决?
谢谢您的帮助
【问题讨论】:
-
代码中断为这一行:
myWord = Dispatch('Word.Application')。你能确认这也是你的情况吗? -
此行没有问题(错误地复制了两次)
-
好吧,我没有消息,只有
libre office,所以帮不上忙。希望其他人解决...
标签: python python-3.x ms-word win32com azure-information-protection