Excel의 통합 문서에서 모든 차트를 그래픽으로 쉽게 내보내는 방법을 찾으려고합니다. 다음 코드를 가지고 있습니다 :모든 차트를 그래픽으로 내보내기
Option Explicit
Sub ExportChart()
' Export a selected chart as a picture
Const sSlash$ = "/"
Const sPicType$ = ".png"
Dim sChartName$
Dim sPath$
Dim sBook$
Dim objChart As ChartObject
On Error Resume Next
' Test if there are even any embedded charts on the activesheet
' If not, let the user know
Set objChart = ActiveSheet.ChartObjects(1)
If objChart Is Nothing Then
MsgBox "No charts have been detected on this sheet", 0
Exit Sub
End If
' Test if there is a single chart selected
If ActiveChart Is Nothing Then
MsgBox "You must select a single chart for exporting ", 0
Exit Sub
End If
Start:
sChartName = Application.InputBox("Please Specify a name for the exported chart" & vbCr & _
"There is no default name available" & vbCr & _
"The chart will be saved in the same folder as this file", "Chart Export", "")
' User presses "OK" without entering a name
If sChartName = Empty Then
MsgBox "You have not entered a name for this chart", , "Invalid Entry"
GoTo Start
End If
' Test for Cancel button
If sChartName = "False" Then
Exit Sub
End If
' If a name was given, chart is exported as a picture in the same
' folder location as their current file
sBook = ActiveWorkbook.Path
sPath = sBook & sSlash & sChartName & sPicType
ActiveChart.Export Filename:=sPath, FilterName:="PNG"
End Sub
이것은 활성 차트를 내 보내지 만 모든 차트를 내보내려면 어떻게해야합니까? 보너스는 차트의 출처가 워크 시트의 이름을 따서 명명 된 경우 나타납니다.
파일 이름에서 "_1"의 근거는 무엇입니까? – fromabove
한 장에 두 개 이상의 차트가있는 경우 동일한 파일 이름을 부여 할 수 없습니다 ... 귀하의 질문에서 차트가 몇 개인 지 명확하지 않았습니다. –
이 경우 한 장에 하나의 차트 만 표시되지만 통화는 좋습니다. 당신의 도움을 주셔서 감사합니다! – fromabove