Word Runtime Error reporting anomaly

J

Julian Ladbury

While investigating a problem with the DocumentMapPercentWidth property in
Word 2010, I discovered that the reporting of the runtime error it throws
differs depending on whether the code executes in the ThisDocument module or
in a 'User' module. In particular, if executed from ThisDocument the error
number is omitted. As this could hamper debugging efforts, I would suggest
that the error number is included in a future release.

I have uploaded an illustrative document to
http://cid-75e3e350f569b887.skydrive.live.com/self.aspx/.Public/Word2010 Runtime Error Reporting.doc

(Note: this difference in error reporting might also be the case with other
versions of Word - I have not tried them as the particular problem I was
investigating is peculiar to 2010).
 
J

Ji Zhou

Hello Julian,

Thanks for your reporting! I can reproduce the scenario. Actually the error
number is only omitted if we run the Macro from the Macro dialog. If we
click the codes context in the ThisDocument module and directly debug from
there, the error number and message pops up both.

I think if we want to more control the error reporting channel and content
in VBA project, we can write our own Error handler.

See these codes. This should be a good way to handle errors and popup useful
information we want,
--------------------
Sub Test()
On Error GoTo EHandler:

ActiveWindow.DocumentMapPercentWidth = 25

EHandler:
MsgBox Err.Number & vbNewLine & Err.Description
End Sub
--------------------

Let me know if this helps? Have a nice day! :)

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
J

Julian Ladbury

Thanks Colbert. As well as when running the macro from the Run Macro dialog,
the difference can be seen when running from an AutoOpen module. That is
where I think the scope for slowing down debugging comes in.

The scenario I envisage is that a customer encounters a runtime error long
after I have shipped product (by which time I have no opportunity to use
Debug or add any error handler). The lack of the error number in such
circumstances could delay diagnosis - and when you have a disgruntled
customer on the phone, speed is of the essence!

This is not a high priority issue by any means, but I would appreciate it if
you could feed back my comments to the relevant team. Someone somewhere must
have decided to omit the error number, and I can see no good reason to do so.
 
C

Colbert Zhou [MSFT]

Sure. I will log it. :)

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top