How to close read-only file when Document_Close Event raises error

W

wal

Vista
Office 2007

Sorry is this is a cross-post, but Google posted my query initially,
and then it disappeared.

I have a Document_Close sub (event) in ThisDocument in Normal that
saves the active document and then saves a backup in another location.

Before the ActiveDocument.Saved code at the top, I have the following
code in an attempt to avoid problems when closing a read-only file
without saving it as something; I just want to close it:

If ActiveDocument.ReadOnly = True Then
On Error GoTo Handler
Dim rYesponse
rYesponse = MsgBox("[instructions: Press OK to close the file
without saving; press Cancel to go back to the file and save it.]",
33, "Read-only file!!")
If rYesponse = vbOK Then
ActiveDocument.Saved = True [probably a superfluous line]
ActiveDocument.Close [ERROR 4198 appears here if handler code
omitted.]
Else:
Exit Sub
On Error GoTo 0
End If
On Error GoTo 0
End If

At the end, I have this code in a Handler:

If Err.Number = 4198 Then
On Error Resume Next
ActiveDocument.Close
On Error GoTo 0
End If

Even with the resume next line, error 4198 appears at the
ActiveDocument.Close line.

Anyway, how can I close the file without further ado. Thanks.
 
W

wal

Answer to self:

The problem resolves itself by putting simply "Exit Sub" in the
Handler.
 

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