Prevent Popup Window when Opening Azure RMS Protected Files

PoeticRobot

New Member
Joined
Nov 19, 2019
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm currently working on a project to run through a list of files on a network drive and report the SQL connections and VBA Modules within each file.
I am running into an issue where a file is protected using Azure RMS and I do not have access to the file - I am presented with a popup window asking me to sign in to an account which has permission to open the file.
I am trying to suppress this popup and record that the file is locked so that I can move on to the next file, but can't find how to prevent the popup occurring.

Below is the code I am using to open my files,

VBA Code:
Set wbkTarget = Nothing
On Error Resume Next

Set wbkTarget = Workbooks.Open(FileName:=strDir & intFileID & "_" & strFileName, WriteResPassword:="!!!") 'Known incorrect password - If file not password protected, file will open
    If Not wbkTarget Is Nothing Then
        intPassword = 0 'No Password Protection
        GoTo FileOpen
    End If

Set wbkTarget = Workbooks.Open(FileName:=strDir & intFileID & "_" & strFileName, UpdateLinks:=False, WriteResPassword:=strPass, IgnoreReadOnlyRecommended:=True) 'strPass is standard password for most files
    If Not wbkTarget Is Nothing Then
        intPassword = 1 'Password exists - Standard password works
        GoTo FileOpen
    End If

Set wbkTarget = Workbooks.Open(FileName:=strDir & intFileID & "_" & strFileName, UpdateLinks:=False, ReadOnly:=True)
    If Not wbkTarget Is Nothing Then
        intPassword = 2 'Password Exists - Password Unknown - File Opened Read-Only
        intPassUnkn = intPassUnkn + 1 'Logs total number of files with unknown password for output at end of code
        GoTo FileOpen

FileOpen:
On Error GoTo Proc_Err
        
        basDetail.Header strFileName, strFilePath, lngRowHeader, intPassword, wbkTarget, intFileID
        basDetail.Detail strFileName, strFilePath, lngRowDetail, wbkTarget, intFileID
        wbkTarget.Close
    Else
        intPassword = 3 'Cannot open file
        intPassUnkn = intPassUnkn + 1 'Logs total number of files with unknown password for output at end of code
        
        With ThisWorkbook.Sheets("Header")
            .Cells(lngRowHeader, 1).Value = intFileID
            .Cells(lngRowHeader, 2).Value = strFileName
            .Cells(lngRowHeader, 3).Value = strFilePath
            .Cells(lngRowHeader, 4).Value = intPassword
            .Cells(lngRowHeader, 5).Value = "Unable to Open File"
        End With
    End If

Can anyone suggest how I can suppress the popup dialog box, OR check for RMS file protection before the file is opened?

Thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
For anyone who has the same issue as me, as far as I am aware, this popup window cannot be prevented through Excel.
I tried the obvious things, like setting EnableAlerts to FALSE, but nothing helped. The Azure RMS protection brings up the popup in Windows, rather than in Excel, which is why VBA cannot provide a solution.

I am working on a solution using Powershell, as Azure Information Protection comes with a module for Powershell. There is a cmdlet called Get-AIPFileStatus which lists details about a specified file, including a field called "IsRMSProtected". If I pass my list of files through this command first, I can remove any files which I know will not be accessible.
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,772
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top