How to handle Cancel on Save?

J

John... Visio MVP

I have a template that occassionally issues a Save
Odoc.Save
when a new segment is started to keep the file up to date. The first time
the Save is called there is no file name associated with the file and the
Save dialog appears and the user can hit the Cancel button. If that happens,
the save failes with a Run Time error of 4198.

Is there anyway this error can be avoided?

John... Visio MVP
 
D

Doug Robbins - Word MVP

Hi John,

The first time use:

With Dialogs(wdDialogFileSaveAs)
If .Show = -1 Then
.Execute
Else
MsgBox "You pressed Cancel."
Exit Sub
End If
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

John... Visio MVP

Thanks Doug, I actually came up with an alternate. Use "On Error Resume
Next"

So what actually is your code doing?
You do a Show Dialogs and if the returned value is -1 you execute the
Dialogs? I thought the Show and Execute were a packaged deal. You can not do
one without the other.

I really do not like casually throwing around "On Error" statements into the
code. Your code ( once encapsulated in a routine) looks cleaner.

John... Visio MVP
 

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