0
votes

I apologize in advanced if this is a basic question. I am new to this community and VBA. I'm using the following Macro in Word 2011 without issue:

    ActiveDocument.Save

    On Error Resume Next

    Dim saveName As String
    saveName = ActiveDocument.FullName
    saveName = Left(saveName, Len(saveName) - 5) & ".pdf"

    ActiveDocument.SaveAs fileName:=saveName, _
      FileFormat:=wdFormatPDF
End Sub

I want to be able to use this in Word 2016 for Mac. I know there are sandboxing restrictions which is causing a permission dialog box to appear every time I want to run this macro. IF I understand correctly: once I give permission to a specific folder, that permission will be saved and I won't be prompted again when running macros that need access to that specific folder. So, for instance, I gave permission to my Dropbox folder. However, as part of my workflow, I am routinely creating new subfolders and each subfolder (under my Dropbox folder) apparently needs individual permission also.

I did some searching online and found that "GrantAccessToMultipleFiles" allows for an array to be created to give permission to files so that these dialog boxes do not keep coming up. My question then is: can I somehow give permission to my Dropbox folder and ANY subfolders that exist or are subsequently created?

1
Side Note: Avoid using On Error Resume Next this mutes any errors and you don't get any messages if there are errors. Have a look at VBA Best Practices - Error Handling to see how to use a proper error handling instead. - Pᴇʜ
Did you solve this? I'm very confused with the Office documentation, I want to save files on a folder, but I don't understand if I can use GrantAccessToMultipleFiles with the new file path (the file doesn't exist yet) or the folder's path where I want to save the file. - Gonzalingui

1 Answers

0
votes

I think you cant. As a workaround you can save the file to the UBF8T346G9.Office folder and move the file via applescript. Its a bit tricky but doable.