![]() ![]() I tested that by exiting Excel, reentering and deleting another file. Once given, future file deletes in the directory won't trigger the permission request. The first time the Apple Script executes, Mac OS will ask for permission for Excel to manipulate files in the directory where the file to be deleted is located. The Kill.applescript file must be stored in /Users/your user name/Library/Application Scripts//Kill.applescript Tell application "System Events" to delete alias fileName # implementation of vba kill command on Mac. Here is the Kill.applescript file contents: on Kill(fileName) S = AppleScriptTask("Kill.applescript", "Kill", fname) If Left(Application.OperatingSystem, 3) = "Mac" Then ![]() Here is the myKill subroutine: Sub myKill(fname As String) It's worthless without the first three steps. Not sure this step was necessary but I mention it as it's my current configuration. Granted Excel Full Disk access in System Preferences/Security & Privacy/Privacy. Globally replaced all calls to Kill with myKill in my VBA code.Īdded a new VBA subroutine called myKill (code below)Ĭreated an AppleScript file to actually remove the file (code below) To workaround the issue, I created a wrapper for VBA's Kill function called myKill. My script is supposed to run once every 3 minutes day and night so responding to separate prompts wouldn't cut it. I wanted to delete a file in Excel using VBA's Kill syntax and got the permission prompt when the VBA attempted to execute the command. 'Create an array with file paths for which permissions are neededįilePermissionCandidates = Array("/Users//Desktop/test1.txt", "/Users//Desktop/test2.txt")įileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates) 'returns true if access granted, false otherwise Note: Once granted, the permissions are stored with the app and user need not grant permission to the file anymore. False - The user denies permission to the files.True - The user grants permission to the files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |