300x250
열려진 워드에 접근하기 위해서 win32com을 import해서 사용
from win32com.client import Dispatch
def set_sensitivitylabel():
word = win32.gencache.EnsureDispatch('Word.Application')
word.Visible = True
doc = word.Documents
# 이미 열린 문서가 없음
if doc.Count == 0:
return
for docs in word.Documents:
# label 생성
new_label = docs.SensitivityLabel.CreateLabelInfo()
new_label.LabelName = ''
new_label.LabelId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
docs.SensitivityLabel.SetLable(new_label, new_label)
return
label 생성 시 label id는 compliance portal에서 생성한 민감도 레이블로부터 찾거나 powershell을 사용해서 직접 조회
오피스 사용 시 로컬에 설치된 policy.xml로부터 참조 가능
민감도 레이블 관련 powershell을 사용하는 방법에 대한 내용이 잘 정리되어 있습니다.
300x250
'Python' 카테고리의 다른 글
AttributeError: module 'win32com.gen_py.' has no attribute 'CLSIDToClassMap' (0) | 2023.05.02 |
---|---|
python을 사용해서 Office에서 이미지 추출 (0) | 2023.04.06 |
python을 사용해서 오피스 문서 포맷 변환 (0) | 2023.04.06 |
ImportError: DLL load failed while importing win32api: 지정된 모듈을 찾을 수 없습니다. (0) | 2022.02.05 |
Python zip 함수 (0) | 2019.07.17 |