#1
|
|||
|
|||
Trap Word Error
I'm running a Word macro from Outlook on a file that is an attachment to an email message. When Word is started, WordApp.visible is set to FALSE.
Today the routine quit working on one PC in our office. No error; it just stopped executing. By changing WordApp.visible to TRUE, I was eventually able to discover that the code had stopped because of the following error in a dialog box that was open behind all other windows: "Document Caused a Serious Problem When It Was Opened Last Time". Once I found the message and clicked that it was OK to open the file, the rest of the code worked fine. So here's my question: Is there a way to trap for this error in vba? |
#2
|
|||
|
|||
Put and On Error statement before you attempt to open the file e.g.,
On Error GoTo Err_Handller Then before the End Sub Line add: lbl_Exit: Exit Sub Err_Handler: Msgbox Err.Number & " " & Err.Description Resume lbl_Exit |
#3
|
|||
|
|||
Trap Word Error
Thank you. Ugh! I have error handlers in most subs/functions, but for some reason I didn't put it in this one and didn't think to check that. Again, thank you.
|
Tags |
error trapping, hidden dialog box, word vba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word template with Macro keeps getting an error ''Run-time error 5941'' | Marcel | Word VBA | 3 | 12-17-2019 04:55 PM |
Word Error Message Run time Error 4605 | baes10 | Word VBA | 1 | 08-30-2018 02:37 PM |
Array to iterate through variables and trap blank variables | Marrick13 | Word VBA | 5 | 08-04-2015 06:19 AM |
Word Visual Basic error - run time error 504 | crazymorton | Word | 11 | 01-13-2012 04:32 AM |
Runtime error 5487 - Word cannot complete the save to to file permission error | franferns | Word | 0 | 11-25-2009 05:35 AM |