VB
Microsoft 开发的一种面向对象的编程语言,其在 .NET Framework 上实现。 以前称为 Visual Basic .NET。
76 个问题
How to Grant One-Time Access for VBA to Read an External Folder on Mac in Office 2021
When running Excel VBA (7.1) in Office 2021 on a Mac, it needs to read multiple TXT files (over 200) in a specific folder. However, a pop-up message appears requiring additional permissions to access each TXT file, which requires manual approval for every single file.
How can I grant VBA one-time permission to access an entire folder (including all the files within it) on a Mac?
Hi,
Try this command in VBA:
Sub requestFileAccess()
'Declare Variables
Dim fileAccessGranted As Boolean
Dim filePermissionCandidates
'Create an array with file paths for the permissions that are needed.
filePermissionCandidates = Array("/Users/YourUsername/Desktop/FolderName/test1.txt", _
"/Users/YourUsername/Desktop/FolderName/test2.txt", _
"/Users/YourUsername/Desktop/FolderName/test3.txt")
'Request access from user.
fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)
'Returns true if access is granted; otherwise, false.
If fileAccessGranted Then
MsgBox "Access granted to all files."
Else
MsgBox "Access denied to one or more files."
End If
End Sub