Hi Marco:
I'd think that "On Error Resume Next" would work, but I guess it's all in
the timing.
Since I never have come up with this issue when opening documents, some of
which have been corrupt, I looked at my boilerplate code that I use all the
time, and lo and behold there are 2 statements which catch errors. One tries
to open the document from a getobject to a createobject, and if this doesn't
work, the other traps the error in an "application.quit" statement. Here is
the sample code:
Dim accessword As AccessObject
Dim oword As Word.Application
Dim wordwasnotrunning As Boolean
Set oword = GetObject("C:\Foldername\MyNewWordDoc.doc", "Word.Application")
oword.Application.Visible = True
If Err.Number <> 0 Then
Set oword = CreateObject("Word.Application")
End If
If Wordwasnotrunning = True Then
oword.Application.Quit
End If
With oword
.WindowState = wdWindowStateMaximize
End With
Set oword = Nothing
Try that and see if this resolves the issue...
Cheers,
Al
Co said:
Hi Marco,
You need to add some error-trapping to your code. At its most basic, that could be an
On Error Resume Next
statement strategically placed in your code.
--
Cheers
macropod
[MVP - Microsoft Word]
Hi All,
we have a procedure which automatically opens a batch of doc files
from within an access database
and searches these docs for certain important words. Sometimes there
is a document that has gone corrupt.
When the procedure stumbles across this document the code stops.
Is there any way to prevent this?
Regards
Marco- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
I think when Word is opening a file the error won't get trapped before
the message gets to the screen
telling you that the file might be corrupted. That way I can't skip
this file before the error is detected.
Marco