home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / wsh.cab / excel.vbs < prev    next >
Text File  |  1997-09-28  |  3KB  |  99 lines

  1. ' Windows Script Host Sample Script
  2. '
  3. ' ------------------------------------------------------------------------
  4. '               Copyright (C) 1996 Microsoft Corporation
  5. '
  6. ' You have a royalty-free right to use, modify, reproduce and distribute
  7. ' the Sample Application Files (and/or any modified version) in any way
  8. ' you find useful, provided that you agree that Microsoft has no warranty,
  9. ' obligations or liability for any Sample Application Files.
  10. ' ------------------------------------------------------------------------
  11.  
  12. ' This sample will display Windows Scripting Host properties in Excel.
  13.  
  14. L_Welcome_MsgBox_Message_Text    = "This script will display Windows Scripting Host properties in Excel."
  15. L_Welcome_MsgBox_Title_Text      = "Windows Scripting Host Sample"
  16. Call Welcome()
  17.     
  18.  
  19. ' ********************************************************************************
  20. ' *
  21. ' * Excel Sample
  22. ' *
  23. Dim objXL
  24. Set objXL = WScript.CreateObject("Excel.Application")
  25.  
  26. objXL.Visible = TRUE
  27.  
  28. objXL.WorkBooks.Add
  29.  
  30. objXL.Columns(1).ColumnWidth = 20
  31. objXL.Columns(2).ColumnWidth = 30
  32. objXL.Columns(3).ColumnWidth = 40
  33.  
  34. objXL.Cells(1, 1).Value = "Property Name"
  35. objXL.Cells(1, 2).Value = "Value"
  36. objXL.Cells(1, 3).Value = "Description"
  37.  
  38. objXL.Range("A1:C1").Select
  39. objXL.Selection.Font.Bold = True
  40. objXL.Selection.Interior.ColorIndex = 1
  41. objXL.Selection.Interior.Pattern = 1 'xlSolid
  42. objXL.Selection.Font.ColorIndex = 2
  43.  
  44. objXL.Columns("B:B").Select
  45. objXL.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft
  46.  
  47. Dim intIndex
  48. intIndex = 2
  49.  
  50. Sub Show(strName, strValue, strDesc)
  51.     objXL.Cells(intIndex, 1).Value = strName
  52.     objXL.Cells(intIndex, 2).Value = strValue
  53.     objXL.Cells(intIndex, 3).Value = strDesc
  54.     intIndex = intIndex + 1
  55.     objXL.Cells(intIndex, 1).Select
  56. End Sub
  57.  
  58. '
  59. ' Show WScript properties
  60. '
  61. Call Show("Name",           WScript.Name,           "Application Friendly Name")
  62. Call Show("Version",        WScript.Version,        "Application Version")
  63. Call Show("FullName",       WScript.FullName,       "Application Context: Fully Qualified Name")
  64. Call Show("Path",           WScript.Path,           "Application Context: Path Only")
  65. Call Show("Interactive",    WScript.Interactive,    "State of Interactive Mode")
  66.  
  67.  
  68. '
  69. ' Show command line arguments.
  70. '
  71. Dim colArgs
  72. Set colArgs = WScript.Arguments
  73. Call Show("Arguments.Count", colArgs.Count, "Number of command line arguments")
  74.  
  75. For i = 0 to colArgs.Count - 1
  76.     objXL.Cells(intIndex, 1).Value = "Arguments(" & i & ")"
  77.     objXL.Cells(intIndex, 2).Value = colArgs(i)
  78.     intIndex = intIndex + 1
  79.     objXL.Cells(intIndex, 1).Select
  80. Next
  81.  
  82.  
  83.  
  84. ' ********************************************************************************
  85. ' *
  86. ' * Welcome
  87. ' *
  88. Sub Welcome()
  89.     Dim intDoIt
  90.  
  91.     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text, _
  92.                       vbOKCancel + vbInformation,    _
  93.                       L_Welcome_MsgBox_Title_Text )
  94.     If intDoIt = vbCancel Then
  95.         WScript.Quit
  96.     End If
  97. End Sub
  98.  
  99.