我有一个宏,可以创建和保存多个 Word 和 Excel 文档。最近,我的组织开始使用 Microsoft Azure 保护。它总是要求用户在保存文档时选择分类标签。有没有办法可以通过VBA传递标签? (即通过代码控制分类)
我尝试搜索现有问题,但没有成功。
最佳答案
一年多了,好像还是没有解决办法。至少我没有找到任何 AIP 的 native VBA 集成。
但是我为自己找到了解决方案。基本上,我现在手动创建邮件草稿,并手动选择分类。该草稿保留在 Outlook 中的一个特殊文件夹中。一旦我需要通过 VBA 发送邮件,我就会复制草稿(包括分类!),更改收件人、对象、正文,并且无需 VBA 的用户交互即可发送邮件,因为分类已经完成。
Private Sub Email()
Dim oMailItem As Outlook.MailItem
'Set oMailItem = Outlook.Application.CreateItem(olMailItem)
'Choose template according to subject
'I have one template for each sensitivity classification
Set oMailItem = getVbaTemplateMail("VBA Template - Sensitivity=General")
With oMailItem
.To = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="19747870755978377b" rel="noreferrer noopener nofollow">[email protected]</a>"
.subject = "Email Test using VBA"
.Body = "Test"
.Display
.Send
End With
Set oMailItem = Nothing
End Sub
Private Function getVbaTemplateMail(subject As String) As Outlook.MailItem
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Outlook.MailItem
'GetDefaultFolder(16) = Draft folder, "Drafts/VBA Templates" is my VBA Template folder
Set olFolder = Application.GetNamespace("MAPI").GetDefaultFolder(16).Folders("VBA Templates")
For Each olItem In olFolder.Items
Debug.Print olItem.subject ' Print to immediate window
If olItem.subject = subject Then
Set getVbaTemplateMail = olItem.Copy
'If error "Active Inline Response" appears, the mail is open in Outlook, close it first!
Exit Function
End If
Next
End Function
关于excel - 使用 vba 的 Azure 分类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49003285/