' Windows Script Host Sample Script L_Welcome_MsgBox_Message_Text = "このスクリプトは Excel に Windows スクリプティング ホストのプロパティを表示します。" L_Welcome_MsgBox_Title_Text = "Windows スクリプティング ホスト サンプル" Call Welcome() ' ******************************************************************************** ' * ' * Excel Sample ' * Dim objXL Set objXL = WScript.CreateObject("Excel.Application") objXL.Visible = TRUE objXL.WorkBooks.Add objXL.Columns(1).ColumnWidth = 20 objXL.Columns(2).ColumnWidth = 30 objXL.Columns(3).ColumnWidth = 40 objXL.Cells(1, 1).Value = "プロパティ名" objXL.Cells(1, 2).Value = "値" objXL.Cells(1, 3).Value = "説明" objXL.Range("A1:C1").Select objXL.Selection.Font.Bold = True objXL.Selection.Interior.ColorIndex = 1 objXL.Selection.Interior.Pattern = 1 'xlSolid objXL.Selection.Font.ColorIndex = 2 objXL.Columns("B:B").Select objXL.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft Dim intIndex intIndex = 2 Sub Show(strName, strValue, strDesc) objXL.Cells(intIndex, 1).Value = strName objXL.Cells(intIndex, 2).Value = strValue objXL.Cells(intIndex, 3).Value = strDesc intIndex = intIndex + 1 objXL.Cells(intIndex, 1).Select End Sub ' ' Show WScript properties ' Call Show("Name", WScript.Name, "アプリケーションの登録名") Call Show("Version", WScript.Version, "アプリケーションのバージョン") Call Show("FullName", WScript.FullName, "アプリケーションのコンテキスト: フルパス") Call Show("Path", WScript.Path, "アプリケーションのコンテキスト: パスのみ") Call Show("Interactive", WScript.Interactive, "対話モードの状態") ' ' Show command line arguments. ' Dim colArgs Set colArgs = WScript.Arguments Call Show("Arguments.Count", colArgs.Count, "コマンドライン引数の数") For i = 0 to colArgs.Count - 1 objXL.Cells(intIndex, 1).Value = "Arguments(" & i & ")" objXL.Cells(intIndex, 2).Value = colArgs(i) intIndex = intIndex + 1 objXL.Cells(intIndex, 1).Select Next ' ******************************************************************************** ' * ' * Welcome ' * Sub Welcome() Dim intDoIt intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _ vbOKCancel + vbInformation, _ L_Welcome_MsgBox_Title_Text ) If intDoIt = vbCancel Then WScript.Quit End If End Sub