Yes, that could be a reason. The /Library/Application Support/ directory on macOS is typically a protected system directory, and writing to it usually requires administrative privileges. If your script attempts to copy a file to this directory without the necessary permissions, it will fail.
To address this issue, you have a few options:
Modify your AppleScript to request administrator privileges when performing the copy operation. This can be done using the with administrator privileges clause in the do shell script command within AppleScript. However, be aware that this will prompt the user for their administrator password.
Here’s an example of how you might modify the script:
tell application "Finder"
set userResponse to display dialog "Is it OK to copy a library to Library/Application Support/Microsoft?" buttons {"Yes", "No"} default button 2
if button returned of userResponse is "Yes" then
set sourceFile to "/path/to/your/file.dylib" -- Update this with the actual path
set targetFolder to "/Library/Application Support/Microsoft" -- Target folder
do shell script "cp " & quoted form of sourceFile & " " & quoted form of targetFolder with administrator privileges
display dialog "Error: " & errMsg
If requiring administrator access is not ideal, consider copying the file to a user-level directory instead, where admin privileges are not needed. For instance, you could use ~/Library/Application Support/, which is specific to the current user and does not require elevated permissions.
Ensure your script properly handles errors and informs the user if the copy operation fails, whether due to permission issues or other reasons.
If you change the AppleScript, remember to update the string in your VBA code accordingly and take care of proper escaping of characters.
Requesting administrator privileges in a script should be done with caution. Ensure that your script is secure and that users are aware of why these privileges are needed. Also, consider the implications of allowing an Excel macro to perform actions that require elevated permissions.
Using these methods, you can either execute the file copy with the necessary permissions or avoid the issue altogether by using a directory that doesn’t require elevated permissions.