The application of VBA in Excel (Iii.)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.