Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2020, 12:08 PM
kjc kjc is offline Trap Word Error Windows 10 Trap Word Error Office 2019
Novice
Trap Word Error
 
Join Date: May 2020
Posts: 12
kjc is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 05-07-2020, 02:17 PM
gmaxey gmaxey is offline Trap Word Error Windows 10 Trap Word Error Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 05-07-2020, 03:36 PM
kjc kjc is offline Trap Word Error Windows 10 Trap Word Error Office 2019
Novice
Trap Word Error
 
Join Date: May 2020
Posts: 12
kjc is on a distinguished road
Default 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.
Reply With Quote
Reply

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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft