Better COM Object error/exception handling through JScript + WSH (over VBScript)

Author Message
daluu

  • Total Posts : 53
  • Scores: 0
  • Reward points : 0
  • Joined: 4/17/2006
  • Status: offline
Better COM Object error/exception handling through JScript + WSH (over VBScript) Monday, April 17, 2006 9:07 AM (permalink)
0
I just wanted to pass this along in case anyone else is interested or encounters the same problem. Please link to the other forum topic areas, if deemed appropriate.

While working on a Word automation project, I found that VBScript does not offer the necessary error handling required when a COM object (Word object in my case) throws an error/exception. Unfortunately, not all COM objects themselves will output an error message, etc. So in my case, depending on the type of error, I might not know that an error occurred and in any case, the Word object still resided in memory because I could not catch the object error using On Error Resume Next + the Err object (which only works for VBScript's default objects and the VBScript language). Standard Visual Basic and VBA might be better though with their additional error handling options.

So if anyone is using WSH and COM objects or Office objects, I "highly" recommend using JScript over VBScript since JScript's try/catch block will catch the object's error no matter what happens.
 
#1
    ebgreen

    • Total Posts : 8219
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: Better COM Object error/exception handling through JScript + WSH (over VBScript) Monday, April 17, 2006 9:15 AM (permalink)
    0
    Even though it may get my Mod priveleges revoked, I will state on the record that I think JScript is a better scripting language for most tasks than VBScript. I however do not have the option of using it at work so I learned VBScript much more thoroughly.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      mbouchard

      • Total Posts : 2110
      • Scores: 29
      • Reward points : 0
      • Joined: 5/15/2003
      • Location: USA
      • Status: offline
      RE: Better COM Object error/exception handling through JScript + WSH (over VBScript) Tuesday, April 18, 2006 1:36 AM (permalink)
      0

      ORIGINAL: ebgreen

      Even though it may get my Mod priveleges revoked, I will state on the record that I think JScript is a better scripting language for most tasks than VBScript. I however do not have the option of using it at work so I learned VBScript much more thoroughly.


      That's it, you can no longer be a mod, turn in your badge and gun....
      Mike

      For useful Scripting links see the Read Me First stickey!

      Always remember Search is your friend.
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9