Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:11+00:00 2026-05-23T10:40:11+00:00

I am totally not a VBScript developer. But as it usually happens I have

  • 0

I am totally not a VBScript developer. But as it usually happens I have to write a small script to check something. It opens Excel, writes something to it and closes it. But that’s not the point. The point is that I cannot manage to write code for error handling. This script:

Sub Work()
On Error GoTo ErrMyErrorHandler
Dim objExcelApp
Dim wb
Dim ws

Set objExcelApp = CreateObject("Excel.Application")
Set wb = objExcelApp.Workbooks.Add(True)
Set ws = wb.Sheets(1)

ws.Cells(1,1).Value = "Hello"
ws.Cells(1,2).Value = "World"

wb.SaveAs("c:\test.xls")
objExcelApp.Quit()
Exit Sub

ErrMyErrorHandler:
MsgBox Err.Description, vbExclamation + vbOKCancel, "Error: " & CStr(Err.Number)    
End Sub

Work()

gives this error:

error

Line 2 is the line with the On Error statement. What am I doing wrong?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:40:11+00:00Added an answer on May 23, 2026 at 10:40 am

    looks like you can not point custom label to error handler in VB Script. You can only use

    on error goto 0 '(raises exceptions)
    on error resume next '(ignores exceptions)
    

    if you use the second syntax, you can catch occurring exceptions via Err global variable:

      if Err.Number <> 0 then MsgBox "Exception occurred: " & Err.Description
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not totally convinced this is possible, but here goes. I have a method
Are there any good books for a relatively new but not totally new *nix
In my case I want to write an app which is totally symetrical (not
I kind of understand what's retain counts for. But not totally. I looked on
I have an interesting situation, well it's probably not that unique at all, but
I'm trying to merge these two object but not totally sure how.. Can you
This question may be redundant, but i could not totally understand how to do
I'm assuming I need to use JOIN, but I'm not totally getting it. Here's
I am not totally sure about C, but C++ allows unnamed bit-fields of 0
I'm totally not good at jQuery, but this is getting hilarious. Searching the web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.