PoeticRobot
New Member
- Joined
- Nov 19, 2019
- Messages
- 10
- Office Version
- 365
- Platform
- 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,
Can anyone suggest how I can suppress the popup dialog box, OR check for RMS file protection before the file is opened?
Thanks.
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.