I have an application written in Microsoft Access using VBA which opens Excel files, processes the contents in various ways and then closes them. If the a file cannot be opened, then I need to detect this and skip the file otherwise the application effectively freezes.
The Excel files come from numerous sources and if they are restricted I don't have the account credentials to open them.
With a password protected file I can supply an incorrect password, detect the error and then skip the file.
Application.Workbooks.Open(FileName, False, , , "xxxx", , True)
If the Excel file has had IRM (Information Rights Management) Restrictions applied to it, then when you open the file in the Excel application you are prompted to sign into Excel with an account that has permission to open the file.
If you try to open the file using the VBA code above with the Excel application not visible, then the process just halts and no error is generated.
What I need to do is either detect that the file has IRM applied to it before trying to open it or try to open it and generate an error that I can detect.
Thanks in advance for any help in solving this.
question from:
https://stackoverflow.com/questions/65905721/detect-if-excel-file-has-irm-information-rights-management-restrictions-using 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…