Method 'SetLabel' of Object 'ISensitivityLabel" failed in Visio VBA

Didier 5 Reputation points
2024-07-01T07:52:02.21+00:00

Hello .

I have written a VBA script from a MS Visio file.

In this script, I am creating an excel file from a Visio Report, and need to assign a sensitivity label (as requirement by my company) before saving it.

I use the code below.

It works fine when I use debug / step by step mode.

But when I run it, I get the following error on the last line of code

image_2024-07-01_095046301

Anybody can help me?

Thx

 Dim Context As Variant

    Set Context = CreateObject("Scripting.Dictionary")

    Dim LBInfo As Office.LabelInfo

    Set LBInfo = objExcel.SensitivityLabel.CreateLabelInfo()

    With LBInfo

        .AssignmentMethod = MsoAssignmentMethod.PRIVILEGED

        .LabelName = "company Confidential"

        .ContentBits = 4

        .IsEnabled = True

        .SetDate = Now()

        .LabelId = "my company label...."   ' company confidential Label

    End With

    objExcel.SensitivityLabel.SetLabel LBInfo, Context


Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,349 questions
Visio
Visio
A family of Microsoft products used to create diagrams and vector graphics.
87 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,715 questions
0 comments No comments
{count} vote