locked
Mac Word VBA Sandbox RRS feed

  • Question

  • As of Word 2016, I can no longer access files with VBA except in the new 'sandbox'. But I researched, and Microsoft has a special command to let the user authorize broader access. But it won't work!

    I have tried the GrantAccessToMultipleFiles command, using the filerequestaccess sample at [https:] //msdn.microsoft.com/en-us/vba/office-mac-vba/grantaccesstomultiplefiles.

    But I can't make anything work. I created the described files on the desktop, test1.txt, test2.txt, and then created these 2 macros. But neither worked. The first one doesn't seem to do anything. The second one complains that it can't find the file

    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//Desktop/test1.txt", "/Users//Desktop/test2.txt")

        'Request access from user.?
    fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)
        'Returns true if access is granted; otherwise, false.
        End Sub
        
        Sub testOpen()
        Documents.Open FileName:="/Users//Desktop/test1.txt"
        End Sub
    Friday, February 16, 2018 10:10 PM