-1

Hello Guys i have this simple script where i apply a chart template on 2 Charts in my Spreadsheet. Obviously this works great under Windows 10, Mac Office 2011 but not on Mac Office 2015.

Im gettin an Error, Runtime Error 70 - Permission Denied Both Files are located in the Same folder, and the Names are correct.

 Sub Makro_Setup()
'
' Makro_Setup Makro
    '
' Tastenkombination: Strg+Umschalt+B
'
Worksheets("Auswertung").Activate

Dim path As String   
Dim TheOS As String

TheOS = Application.OperatingSystem

If MAC_OFFICE_VERSION >= 15 Then
MsgBox "Not Good"
Else
MsgBox "Good"
End If

path = ActiveWorkbook.path + "/Diagramm1.crtx"

MsgBox TheOS
MsgBox path

ActiveSheet.ChartObjects("Diagramm 2").Activate
ActiveChart.PlotArea.Select

' Here comes the error 70 -START
ActiveChart.ApplyChartTemplate path
' Here comes the error 70 -END

ActiveSheet.ChartObjects("Diagramm 5").Activate
ActiveChart.PlotArea.Select
ActiveChart.ApplyChartTemplate path

End Sub

Maybe Somebody can help me with this :(

Ps.: the path ist correct: /users/....

Best Regards Machete

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Ma chete
  • 33
  • 6

1 Answers1

0

Ok finally i found the solution to the problem with the Mac office 2016. The problem is that in the new Version you cannot access files just by default. So added following to my Code:

'Declare Variables?
Dim fileAccessGranted As Boolean
Dim filePermissionCandidates

'Create an array with file paths for which permissions are needed?
filePermissionCandidates = Array(path, ActiveWorkbook.path)

'Request Access from User?
fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)       
'returns true if access granted, false otherwise?

Simpy this thread helped me a lot: VB Macros for Office 2016 for Mac require Permissions every time they try to access a file! Is there any way to get around this behavior?

Best Regards Machete

PS. needed to Unprotect the Worksheet too!

Community
  • 1
  • 1
Ma chete
  • 33
  • 6