0
我有一個excel用戶窗體,它允許您將excel圖表保存在某個工作表中,並將其保存到.jpg圖像中,同時在用戶窗體中顯示圖表。但是我發現很難控制所述圖像的分辨率。分辨率似乎取決於工作表上的縮放量。當我放大時,我會得到高質量的圖像,而當我縮小時分辨率變得非常差。有沒有辦法使用vba代碼來控制它?導出圖表的控制分辨率
我使用了出口的代碼如下:
Private Sub CmdBrowse_Click()
Dim Directory1 As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
On Error Resume Next
Directory1 = .SelectedItems(1)
Err.Clear
On Error GoTo 0
End With
ChartDest.Value = Directory1
End Sub
Private Sub CmdLoad_Click()
Dim FilePath As String
Dim Imagename As String
Dim ChartNumber As Integer
If ChartDest = "Select chart destination folder" Then
MsgBox "Select chart destination"
Exit Sub
End If
ChartNumber = ChartList.ListIndex + 1
'saving chart to image
Imagename = ChartList.Value
FilePath = ChartDest & Imagename & ".jpeg"
ThisWorkbook.Worksheets("Blad3").ChartObjects(ChartNumber).Chart.Export FilePath, "jpg"
'loading image
UserForm4.ChartImage.Picture = LoadPicture(FilePath)
End Sub
ChartDest與目標路徑文本框。 Chartlist與繳費圖表列表的列表框
我選擇使用'activewindow.zoom'方法,因爲'scaleheight'和'scalewidth'是對工作方法形狀,而不是圖表或圖表對象。感謝您的解決方案。 – Antares797