0

I'm tried to use PowerPoint-VBA to handle some code exception/error, but I cannot trigger it successfully, even using the simplest example code from the tutorial.

The gif below shows despite I add "On Error" before 6/0 but it still shows divided by zero runtime error.

I've tried similar code on at least 3 different computer with different PowerPoint version 2013, 2016, 2019 respectively but found they all behaves the same.

I would like to know whether I missed something obvious or should I enable or turn on some sort of option in the setting?

Thanks.

The code sample that I use for the test is as below, this is just an example that I found on the net for testing.

Option Explicit
Sub UsingGotoLine()
    On Error GoTo eh
    Dim x As Long, y As Long

    x = 6
    y = 6 / 0
    x = 7

Done:
    Exit Sub

eh:
    MsgBox "The following error occurred " & Err.Description

End Sub

unable to handle error

2
  • Rather than (or in addition to) pasting screenshots of your code, paste the code itself into your question. That'll allow anyone who's trying to help you to copy/paste and test the code themselves. Commented Jan 22, 2022 at 15:58
  • FWIW, I could not reproduce (in PP 2007). In my test my own error message is displayed. Commented Jan 22, 2022 at 16:12

1 Answer 1

1

In the VBA IDE, choose Tools | Options Look at the General tab. If "Break on All Errors" is chosen, I get the same result as you. Effectively, your error handler is disabled. This can be useful to make sure your error handling isn't masking problem.

Instead, select "Break on unhandled errors" and it'll behave as you expect it to.

If not, we'll need to discuss percussive maintenance.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.