<JOB>
<SCRIPT
language="VBScript"
src="http://lightbox.on.coocan.jp/webwsh/GetScriptDir.vbs"
></SCRIPT>
<SCRIPT language=VBScript>
' ***********************************************************
' 新しいグラフを作成する
' ***********************************************************
Dim ExcelApp ' アプリケーション
Dim ExcelBook ' ブック
Dim MySheet
Dim dataRange
Dim chartObjects
Dim newChartObject
Dim MyChart
Dim BookPath
Set ExcelApp = CreateObject("Excel.Application")
' 警告を出さないようにする
ExcelApp.DisplayAlerts = False
' Excel を表示状態にする
'ExcelApp.Visible = True
' ブック追加
ExcelApp.Workbooks.Add
' 追加したブックを取得
Set ExcelBook = ExcelApp.Workbooks( ExcelApp.Workbooks.Count )
' Worksheet を選択 ( 最初のシート )
Set MySheet = ExcelBook.Sheets(1)
' シートへグラフ用データをセット
MySheet.Cells(1, 1) = ""
MySheet.Cells(1, 2) = "Q1"
MySheet.Cells(1, 3) = "Q2"
MySheet.Cells(1, 4) = "Q3"
MySheet.Cells(1, 5) = "Q4"
MySheet.Cells(2, 1) = "N. America"
MySheet.Cells(2, 2) = "1.5"
MySheet.Cells(2, 3) = "2"
MySheet.Cells(2, 4) = "1.5"
MySheet.Cells(2, 5) = "2.5"
MySheet.Cells(3, 1) = "S. America"
MySheet.Cells(3, 2) = "2"
MySheet.Cells(3, 3) = "1.75"
MySheet.Cells(3, 4) = "2"
MySheet.Cells(3, 5) = "2"
MySheet.Cells(4, 1) = "Europe"
MySheet.Cells(4, 2) = "2.25"
MySheet.Cells(4, 3) = "2"
MySheet.Cells(4, 4) = "2.5"
MySheet.Cells(4, 5) = "2"
MySheet.Cells(5, 1) = "Asia"
MySheet.Cells(5, 2) = "2.5"
MySheet.Cells(5, 3) = "2.5"
MySheet.Cells(5, 4) = "2"
MySheet.Cells(5, 5) = "2.75"
' データの範囲
Set dataRange = MySheet.Range(MySheet.Cells(1, 1), MySheet.Cells(5, 5))
Set chartObjects = MySheet.ChartObjects()
' 座標は、グラフのエリア
Set newChartObject = chartObjects.Add(0, 100, 300, 300)
Dim paramChartFormat : paramChartFormat = 1
Dim paramCategoryLabels : paramCategoryLabels = 0
Dim paramSeriesLabels : paramSeriesLabels = 0
Dim paramHasLegend : paramHasLegend = True
Dim paramTitle : paramTitle = "Sales by Quarter"
Dim paramCategoryTitle : paramCategoryTitle = "Fiscal Quarter"
Dim paramValueTitle : paramValueTitle = "Billions"
Set MyChart = newChartObject.Chart
MyChart.ChartType = 54
Call MyChart.SetSourceData( dataRange )
BookPath = GetScriptDir & "\chart.xls"
on error resume next
' 保存
' 56 は、Excel 2007 で拡張子 .xls で保存する場合に必要
if CLng(Left(ExcelApp.Version & "",2 )) > 11 then
Call ExcelBook.SaveAs( BookPath, 56 )
else
Call ExcelBook.SaveAs( BookPath )
end if
if Err.Number <> 0 then
MsgBox( "ERROR:" & Err.Description )
end if
on error goto 0
' Excel をアプリケーションとして終了
ExcelApp.Quit
' Excel を VBScript から開放
Set ExcelApp = Nothing
' オブジェクト変数を通常変数として初期化
ExcelApp = Empty
</SCRIPT>
</JOB>