1
嘗試在Mac Excel 2016中將範圍保存爲jpeg圖像。我運行VB代碼,首先出現此錯誤:「運行時錯誤」-2147287035 (80030005)':指定的維度對當前圖表類型無效。「如果我再次點擊調試,然後F5,我得到這個錯誤:「運行時錯誤'70':權限被拒絕。」VBA Mac Excel 2016:圖表。導出權限被拒絕錯誤70
從我的研究中,前者是沙箱問題或圖表問題。我甚至爲補丁添加了grantAccessToMultipleFiles,但沒有幫助。
有問題的部分:
.Chart.Export Filename:=ThisWorkbook.Path & "/william.jpg", Filtername:="JPG"
下面是完整的代碼:
Sub SaveImage()
'from stackoverflow originally
Dim sSheetName As String
Dim oRangeToCopy As Range
Dim Lastrow As Integer
Dim manager As String
manager = Worksheets("by Mgr").Range("C6").Value
Set b = Worksheets("by Mgr").Range("T:T").Find(what:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues)
Lastrow = b.Row
sSheetName = "by Mgr" ' worksheet to work on
With Worksheets(sSheetName).Range("A1:T" & Lastrow)
.CopyPicture xlScreen, xlPicture
'Getting the Range height
PicHeight = .Height
'Getting the Range Width
PicWidth = .Width
End With
filePermissionCandidates = Array(ThisWorkbook.Path)
fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)
With Worksheets(sSheetName)
'Creating the Chart
.ChartObjects.Add(30, 44, PicWidth, PicHeight).name = manager
With .ChartObjects(manager)
'Pasting the Image
.Chart.Paste
'Exporting the Chart
.Chart.Export Filename:=ThisWorkbook.Path & "/william.jpg", Filtername:="JPG"
End With
.ChartObjects(manager).Delete
End With
End Sub
我對在束手無策,任何想法表示讚賞。
看到這個職位的更多信息:https://stackoverflow.com/questions/15183416/vba-save-cell-contents-to-text-file-in-a-specific-location-on-mac – PerpetualStudent