Azure Information Protection VBA

2022-12-22T23:02:09.257+00:00

Hello, I'm a bit stuck with the macros I'm developing in VBA, the issue is that I have to create and save a lot of excel files in different locations, however, I can't automate the process completly because of the Azure Information Protection window, the question is, there's a way to assign the label with vba for excel? or some other way to make this a bit more agile?

Azure Information Protection
Azure Information Protection
An Azure service that is used to control and help secure email, documents, and sensitive data that are shared outside the company.
560 questions
Developer technologies | Visual Basic for Applications
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2022-12-23T06:53:31.157+00:00

    Hi @JOHNATHAN RODRIGO SERRANO GARCIA ,

    Thanks for reaching out.

    I understand while saving the excel files, Azure Information Protection asking to label the files and you are looking to assign the label using VBA.

    There is the document provided by Microsoft to label the office document using LabelInfo object. In the similar way you can assign the label to Excel workbook to save multiple files in different location.

    Dim myLabelInfo, context  
      
    Set myLabelInfo = objWorkbook.SensitivityLabel.CreateLabelInfo()  
      
    Set context = CreateObject("Scripting.Dictionary")  
      
    With myLabelInfo  
      
      .AssignmentMethod = 1  
      
      .IsEnabled = True  
      
      .LabelId = "--your labelID--"  
      
      .LabelName = "--your label name--"  
      
      .SetDate = Now()  
      
    End With  
      
    objWorkbook.SensitivityLabel.SetLabel myLabelInfo, context  
    

    where Label id and LabelName need to replace with your actual label id and name.
    and SensitivityLabel.SetLabel requires a context object which can be anything if you are not using it.

    You can get the Label details using Get-AIPFileStatus "C:\myFile.xlsx"

    Hope this will help.

    Thanks,
    Shweta

    -------------------------------

    Please remember to "Accept Answer" if answer helped you.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.