excel.pys 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #app=WScript.Application
  2. #app._print_details_() # Use this to see what Python knows about a COM object.
  3. g_index = 1
  4. # A procedure, using a global.
  5. def Show(desc, value = None):
  6. global g_index # Need global for g_index, as I locally assign.
  7. # No global needed to "xl" object, as only referenced.
  8. # Also note "xl" is assigned later in the script - ie, Python is very late bound.
  9. xl.Cells(g_index, 1).Value = desc
  10. if value: xl.Cells(g_index, 2).Value = value
  11. g_index = g_index + 1
  12. xl = WScript.CreateObject("Excel.Application")
  13. import sys
  14. xl.Visible = 1
  15. #xl.Workbooks().Add() # Excel versions before 98
  16. xl.Workbooks.Add()
  17. # Show the WScript properties.
  18. Show("Application Friendly Name", WScript.Name)
  19. Show("Application Version", WScript.Version)
  20. Show("Application Context: Fully Qualified Name", WScript.FullName)
  21. Show("Application Context: Path Only", WScript.Path)
  22. Show("State of Interactive Mode", WScript.Interactive)
  23. Show("All script arguments:")
  24. args = WScript.Arguments
  25. for i in xrange(0,args.Count()):
  26. Show("Arg %d" % i, args(i))