VBS & Excel Files
-
Hi Ladiez & Gentz, this is an example out of my Learn Scripting In 2 Hours Book (Yeah Right) it opens excel and then creates a new workbook and changes some of the cell properties and enters some info but what i want is to open excel and then OPEN a workbook - anyone got any idea on how to thanks in advance Alex T @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ L_Welcome_MsgBox_Message_Text = "This script will display Windows Scripting Host properties in Excel" L_Welcome_MsgBox_Title_Text = "Windows Scripting Host & Excel" '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 = "Property Name" objXL.Cells(1, 2).Value = "Value" objXL.Cells(1, 3).Value = "Description" 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, "Application Friendly Name") Call Show("Version", WScript.Version, "Application Version") Call Show("FullName", WScript.FullName, "Application Context: Fully Qualified Name") Call Show("Path", WScript.Path, "Application Context: Path Only") Call Show("Interactive", WScript.Interactive, "State Of Interactive Mode") 'Show Command line Arguments Dim colArgs Set colArgs = WScript.Arguments Call Show("Arguments.Count", colArgs.Count, "Number of command line arguments") 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_Text, vbOkCancel + vbInformation, L_WelcomeTitleText) If intDoIt = vbCancel Then WScript.Quit End If End Sub