“Grant Access” prompt appears when loading pictures from a local HDD or SMB/NAS path in Excel mac VBA

Julius Calibo 5 Reputation points
2026-08-05T17:48:17.1233333+00:00

Hi Microsoft Support,

I have an Excel workbook with a VBA macro that loads or inserts pictures from a folder.

When the pictures are stored inside the same folder as the Excel workbook, the macro loads them normally and no “Grant Access” prompt appears.

However, the image files are large, and keeping them in the Excel folder uses too much storage space on my laptop. To save laptop storage, I decided to store the pictures on an external HDD or on a NAS through an SMB network share.

The issue is that when the macro loads pictures from the external HDD or SMB/NAS location, Excel displays a “Grant Access” prompt every time. This happens even though I already have permission to access the folder.

Could you please advise how to prevent the repeated “Grant Access” prompt while allowing the VBA macro to load images from the external HDD or SMB/NAS folder? Are there recommended Excel settings, macOS privacy permissions, SMB-share settings, or VBA code changes for this?

I have attached the VBA macro code used to load the pictures for your reference.

Environment details:

  • Excel version: [version]
  • macOS version: [version]
  • Image source: External HDD / NAS SMB network share

Thank you.

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim shp As Shape
    Dim rng As Range, c As Range
    Dim img As String, imgName As String
    Dim lastRow As Long
    Dim formulaD As String
    Dim formulaE As String
    Dim formulaF As String
    Dim formulaG As String
    Dim i As Long
    Dim seqNum As Long
    Dim rowRange As Range
    Dim ws As Worksheet

    Const filepath As String = "/Volumes/test/PICTURES/"

    Set ws = Me
    
    ' Only run code if changes are made in column C
    If Intersect(Target, ws.Columns("C")) Is Nothing Then Exit Sub

    ' Optimize performance
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False

    ' Handle image and text update
    Set rng = Intersect(Target, ws.Range("C2:C" & ws.Rows.Count))
    If Not rng Is Nothing Then
        For Each c In rng
            With c.offset(0, -1)
                imgName = "PictureAt" & .Address
                On Error Resume Next
                ' Delete the existing image if it exists
                If ws.Shapes.Count > 0 Then ws.Shapes(imgName).Delete
                On Error GoTo 0

                ' Determine image path
                img = filepath & c.Value & ".jpg"

                ' Clear cell content and manage "NO PICTURE AVAILABLE"
                If IsEmpty(c.Value) Or Dir(img) = "" Then
                    .ClearContents
                    If IsEmpty(c.Value) Then
                        ' If cell in column C is empty, clear corresponding row from columns A to C
                        ws.Range("A" & c.Row & ":C" & c.Row).ClearContents
                        ' Remove borders if column C is empty
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlEdgeBottom).LineStyle = xlNone
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlEdgeTop).LineStyle = xlNone
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlEdgeLeft).LineStyle = xlNone
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlEdgeRight).LineStyle = xlNone
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlInsideVertical).LineStyle = xlNone
                        ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders(xlInsideHorizontal).LineStyle = xlNone
                        ' Maintain the current row height
                        ws.Rows(c.Row).RowHeight = ws.Rows(c.Row).RowHeight
                    Else
                        ' Cell in column C has a value but no picture found
                        .Value = "NO PICTURE AVAILABLE"
                        .HorizontalAlignment = xlCenter
                        .VerticalAlignment = xlCenter
                        .WrapText = True
                        ' Maintain the current row height
                        ws.Rows(c.Row).RowHeight = ws.Rows(c.Row).RowHeight
                    End If
                Else
                    ' Add picture if it exists
.ClearContents

If Dir(img) <> "" Then

    Dim pic As Picture

    Set pic = ws.Pictures.Insert(img)

    pic.Left = .Left
    pic.Top = .Top

    pic.ShapeRange.LockAspectRatio = msoTrue
    pic.ShapeRange.Height = .Height - 4

End If
                End If
            End With
        Next c
    End If

    ' Add borders to columns A to C if column C is not empty
    For Each c In rng
        If Not IsEmpty(c.Value) Then
            With ws.Range(ws.Cells(c.Row, "A"), ws.Cells(c.Row, "C")).Borders
                .Item(xlEdgeBottom).LineStyle = xlContinuous
                .Item(xlEdgeTop).LineStyle = xlContinuous
                .Item(xlEdgeLeft).LineStyle = xlContinuous
                .Item(xlEdgeRight).LineStyle = xlContinuous
                .Item(xlInsideVertical).LineStyle = xlContinuous
                .Item(xlInsideHorizontal).LineStyle = xlContinuous
            End With
        End If
    Next c

    ' Add sequence numbers in column A
    seqNum = 1

    lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
    For i = 2 To lastRow
        Set rowRange = ws.Range("A" & i & ":C" & i)

        If Application.WorksheetFunction.CountA(rowRange) > 0 Then
            ws.Cells(i, "A").Value = seqNum
            seqNum = seqNum + 1
        Else
            ws.Cells(i, "A").Value = "" ' Clear the cell if column C is empty
        End If
    Next i

    ' Restore settings
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
End Sub



Microsoft 365 and Office | Excel | Other | MacOS
0 comments No comments

1 answer

Sort by: Most helpful
  1. Kai-H 23,815 Reputation points Microsoft External Staff Moderator
    2026-08-06T08:04:54.65+00:00

    Hi, Julius Calibo

    This is caused by the macOS sandbox, not normal SMB or folder permissions. Excel macros cannot freely access external files, so Dir() and Pictures.Insert() may each trigger the prompt.

    Here are some suggestions you can try:

    In System Settings > Privacy & Security > Files and Folders, enable Removable Volumes and Network Volumes for Excel if those options are listed. Restart Excel afterward.

    Request access before calling Dir() or inserting the picture:

    Dim permitted As Boolean
    Dim files As Variant
    
    files = Array(img)
    permitted = GrantAccessToMultipleFiles(files)
    
    If Not permitted Then Exit Sub
    

    Place this immediately after building img, but before Dir(img). Access must be requested using complete POSIX file paths, not just /Volumes/test/PICTURES/. Once permission is granted, it should be stored for that app and file.

    Make sure the NAS is mounted in Finder first and always uses the same volume name under /Volumes. Reconnecting it under a different name can make Excel treat the path as new.

    There is no supported Excel setting or VBA method that completely disables macOS sandbox prompts. If new image names are continuously added, they may require approval because they are new files. Also update Excel to the latest available version before testing again.

    Thank you for your patience in reading, I hope this information has been helpful to you. 


    If the answer is helpful, please click "Yes" and kindly upvote it. If you have extra questions about this answer, please click "Comment."    

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.