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:] //

    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
    Wednesday, February 21, 2018 7:00 PM

All replies

  • Apologies, my reply isn't on the above, but on Kevin Jaques's question where the Excel 2016 ribbon customisation file is stored ("Excel 2016 Ribbon Preferences" at in a thread closed for replies. Hoping that you are the same person, the answer is: ⁨Users/⁨Felix/⁨Library/⁨Containers⁩/⁨⁨Data/⁨Library/⁨Preferences⁩/Excel.officeUI 

    Saturday, January 5, 2019 12:16 PM
  • This is the reason that I am still using MS2011.

    I also used 2001 for a decade.

    Much of the problem is due to Mojave, but some is pure MS

    In previous incarnations, you had to add "as POSIX file" as the old MS used Mac and not Unix file names by default and MS did not resolve the 31 character file name limit in the older versions either.

    I do not know MS 2016 but am an Uber user of 2011 and previous.

    I would avoid using the desktop as a directory

    consider putting the files in a folder and then getting the full path in the immediate window

    ? activedocument.fullname

    this may show you if your delimeters are correct

    Please let me know if you fix this

    I have hundreds of templates and other files, way to many to specify.

    The better answer would be to allow us to place the files into a MS folder which has permissions allowed

    However, this would not help other macros where files are moved from and to other computers over a network

    I have used AppleScript "shims" to perform some of the File manipulation. see below

    Unfortunately AppleScript has also been emasculated in Mojave

    Below are two functions I use to make sure I do not write over an old file when saving a new one[

    Function ThisFileExists(filetobechecked As String) As Boolean

        ' can be used to replace filefind and fileexists

        ' also shows how to pass applescript result to VBA to patch holes

    'test file = "BDP Air:Users:Shared: In Process:BDP AV Opt Sheet.docx”

    ThisFileExists = MacScript("set msg to ""False""" & vbCr & _

    "tell application ""Finder"" to if exists   """ & filetobechecked & """ then set msg to ""True"" " & vbCr & "msg")

    'this uses old mac file sep of ":" if using unix "/" then add "as POSIX file " before "then set msg"

    End Function

    Function UniqueFileName(ByVal aFolder As String, ByVal aFile As String) As String

        Dim theFile As String


                Do While ThisFileExists(aFolder & aFile)

                    aFile = InputBox("This file name is already being used, please change", "Used File Name", aFile)



                UniqueFileName = aFolder & aFile


    End Function

    Scripts have to be stored as files and then opened

    Tuesday, February 5, 2019 7:21 AM