The macro below runs for the first index but gives permission denied (error code 70) in the next index. As can be seen, I have tried a lot of suggestions to grant those permissions but I keep getting the error.
Sub Macro1()
'
' Macro1 Macro
'
'
Dim myPath As String
Dim myName As String
Dim fullname As String
Dim i As Long
Dim filelist() As Variant
Dim shapeChart As Chart
Dim mysheet As Worksheet
myPath = "/Volumes/MyPassport/parameter_studies/roughness/GlennIce_nml/outputs/"
fullname = myPath & "pictures"
ReDim filelist(0)
filelist(0) = fullname
fileAccessGranted = GrantAccessToMultipleFiles(filelist)
For i = 2 To 97
Workbooks("large_and_glaze_adjusted_clean.xlsx").Activate
myName = Cells(i, 1)
fullname = myPath & myName & "/" & myName & "_plots.xlsx"
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Workbooks.Open filename:=fullname
Workbooks(myName & "_plots.xlsx").Activate
Sheets("shape_plot").Select
Set shapeChart = Charts("shape_plot")
fullname = myPath & "pictures/" & myName & ".png"
On Error Resume Next
Kill fullname
On Error GoTo 0
shapeChart.Export filename:=fullname
Set shapeChart = Nothing
Application.DisplayAlerts = False
ActiveWindow.Close
Next i
End Sub
Bookmarks