VBA script doesn't work in MacOS
I have a script in Windows Excel that runs perfectly, capturing a cell range and saving that as a png to a folder. However, when I run on Mac, it seems to finish but there is no image anywhere to be found. I have changed the path to accommodate a Mac, however, it doesn't work.
is the correct path format?
myPath= "Macintosh HD:users:username:Desktop:DestinationFolder:"
I do a step through and the image shows up then deletes as it should but the pic is not in the destination folder. Curious if it has anything to do with the iCloud? If I look at the path of desktop or any folder it is on iCloud.
Sub save_range_as_image()
Dim ws As Worksheet
Dim table As Range
Dim pic As Picture
Dim cht As ChartObject
Dim myPath As String
Dim myPic As String
Dim myWidth As Long
Dim myHeight As Long
Set ws = ThisWorkbook.Sheets("Game.Sheet")
Set table = ws.Range("AD4:AD7")
myPath = "Macintosh HD:Users:username:Desktop:NHL24:Goal.png" -
myPic = "GoalScoredBy.png"
table.CopyPicture xlScreen, xlPicture
myWidth = table.Width
myHeight = table.Height
Set cht = ws.ChartObjects.Add(Left:=10, Top:=40, _
Width:=myWidth, Height:=myHeight)
cht.Activate
With cht.Chart
.Paste
.Export fileName:=myPath & myPic, Filtername:="png"
End With
cht.Delete
End Sub
MacBook Air (M2, 2022)