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

Didier 20 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 and Office | Development | Other
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | Visio | For business | Windows
0 comments No comments
{count} votes

Your answer

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