VBS Script

Here is a sample VBS script. Save it in a standard text file with a .VBS extension.

This example:

  • creates an Excel object,
  • opens a workbook,
  • sets a value,
  • runs a VBA routine,
  • then tidies up and closes down.
     
Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "C:\Byg\textfile\TextFileReformat.xls"
xlObj.Range("NoOfCharsPerLine").Value = 50
xlObj.Run "ReadFromTextFile"
xlObj.ActiveWorkbook.Saved = True
xlObj.ActiveWindow.Close
xlObj.Quit

To run this you must have Windows Scripting Host (WSH) installed.
see: MSDN Online: Windows Scripting
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp

Published: 05-Jun-2004
Last edited: 01-Mar-2011 20:51