Directory
Chart Export
Chart Format
Chart Lengend
Chart Protect
Chart Title
Chart
Chart Export
1. Save the chart in Excel to a picture in GIF format on your hard disk
Sub ExportChart()
Dim myChart As Chart
Set myChart=ActiveChart
myChart.Export Filename:="C:\Chart.gif", Filtername:="GIF"
End Sub
Theoretically charts can be saved to any type of picture file that readers can try for themselves.
2. Export a chart in Excel to an interactive page save to your hard disk
Sub SaveChartWeb()
ActiveWorkbook.PublishObjects.Add _
SourceType:=xlSourceChart, _
Filename:=ActiveWorkbook.Path & "\Sample2.htm", _
Sheet:=ActiveSheet.name, _
Source:=" Chart 1", _
HtmlType:=xlHtmlChart
ActiveWorkbook.PublishObjects(1).Publish (True)
End Sub
Chart Format
1. Manipulate chart objects. For several examples of using VBA to manipulate Excel chart objects, readers can try them on their own.
Public Sub ChartInterior()
Dim myChart As Chart
'Reference embedded chart
Set myChart=ActiveSheet.ChartObjects(1).Chart
With myChart 'Alter interior colors of chart components
.ChartArea.Interior.Color=RGB(1, 2, 3)
.PlotArea.Interior.Color=RGB(11, 12, 1)
.Legend.Interior.Color=RGB(31, 32, 33)
If .HasTitle Then
.ChartTitle.Interior.Color=RGB(41, 42, 43)
End If
End With
End Sub