' Select the contents that need to be in the chart
MyExcelChart.ActiveSheet.Range("b2:k5").Select
' Add the chart
MyExcelChart.Charts.Add
' Format the chart, set type of chart, shape of the bars, show title, get the data for the chart, show datatable, show legend
MyExcelChart.activechart.ChartType = 65
MyExcelChart.activechart.BarShape =3
MyExcelChart.activechart.HasTitle = True
MyExcelChart.activechart.ChartTitle.Text = "Visitors log for each week shown in browsers percentage"
MyExcelChart.activechart.SetSourceData MyExcelChart.Sheets("Sheet1").Range("A1:k5"),1
MyExcelChart.activechart.Location 1
MyExcelChart.activechart.HasDataTable = True
MyExcelChart.activechart.DataTable.ShowLegendKey = True
' Save the the excelsheet to chart.xls
'MyExcelChart.SaveCopyAs "c:\chart.html"
'MyExcelChart.SaveAs ("c:\chart.html",xlHTML)
MyExcelChart.ActiveChart.Export "c:\chart.gif","GIF"
MyExcelChart.SaveAs "c:\chart.html",8 'export to html file
MyExcelChart.objExcelApp.Quit
Set objExcelApp = nothing
%>
<HTML>
<HEAD>
<TITLE>MyExcelChart</TITLE>
</HEAD>
<BODY>
<iframe src="c:\chart.html"></iframe>
</BODY>
</HTML>
错误如下:
Microsoft Excel (0x800A03EC)
Workbook 的 SaveAs 方法无效