wwrightchess
New Member
- Joined
- Apr 20, 2022
- Messages
- 29
- Office Version
- 365
- Platform
- MacOS
I am trying to export charts as png. It works on the first instance but on the second I get permission denied with an error code of 70. tried granting access and setting application alerts to false. Macro below.
Sub Macro1
Dim myPath As String
Dim myName As String
Dim fullname As String
Dim i As Long
Dim filelist() As Variant
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
Application.DisplayAlerts = True
Sheets("shape_plot").Select
fullname = myPath & "pictures/" & myName & ".png"
Application.DisplayAlerts = False
ActiveChart.Export fullname
Application.DisplayAlerts = True
ActiveWindow.Close
Next i
End Sub
Sub Macro1
Dim myPath As String
Dim myName As String
Dim fullname As String
Dim i As Long
Dim filelist() As Variant
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
Application.DisplayAlerts = True
Sheets("shape_plot").Select
fullname = myPath & "pictures/" & myName & ".png"
Application.DisplayAlerts = False
ActiveChart.Export fullname
Application.DisplayAlerts = True
ActiveWindow.Close
Next i
End Sub