I'm writing an Excel macro to automatically populate and save a number of Word docs. It's working great on Office for Mac 2016, but I want to ensure cross-compatibility with Windows.
To reduce the user burden of granting individual file permissions due to Mac Office sandboxing I've implemented the GrantAccessToMultipleFiles command, using ramitarora's helpful solution.
Unfortunately, because GrantAccessToMultipleFiles is a Mac-specific command, I'm running into a Compile error: "Sub or Function not defined" as soon as I try to run this on Windows. Is there a solution to this? Because it's a compile error I can't just run over it using "On Error Resume Next".
For reference, relevant code is below:
'Operating System check: if pos=0, user is on OSX
Dim pos As Integer
pos = InStr(Application.OperatingSystem, "Windows")
'If on OSX ask for file permissions in bulk
If pos = 0 Then
Dim fileAccessGranted As Boolean
Dim filePermissionCandidates
Dim filePathsArray As String
filePathsArray = filePaths(0)
For i = 0 To studentNum
filePathsArray = filePathsArray & ", " & filePaths(i + 1)
Next i
'Create an array with file paths for which permissions are needed
filePermissionCandidates = Array(filePathsArray)
'Request access from user
fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)
End If
Thanks.