wdDialogFileSaveAs - won't overwrite existing filename

Z

zsplash

I have the following code which works fine unless the filename already
exists, in which case it "freezes" and won't do anything, and I am forced to
cancel. How can I modify this code to save an already-existing filename?

Private Sub cmb4SaveAll_click()
Dim CommonDialog3 As Dialog
Set CommonDialog3 = Dialogs(wdDialogFileSaveAs)
On Error Resume Next
With CommonDialog3
.Name = ""
If .Show = 0 Then ' if cancel, exit sub
Exit Sub
End If
End With
End Sub

TIA
 
C

Cindy Meister -WordMVP-

Hi Zsplash,
I have the following code which works fine unless the filename already
exists, in which case it "freezes" and won't do anything, and I am forced to
cancel.
FileSaveAs displays a message that the user has to answer, asking if an
existing file should be overwritten. Most likely, it's not being displayed
where you can see it, for some reason. Maybe if you take ou tthe On Error
Resume Next?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
Z

zsplash

Thanks, Cindy. I have tried adding code to make it so all messages are
displayed, as well as taking on On Error Resume Next, but it still won't
overwrite an existing file. (It saves as new filename just fine.) If the
message box is somehow showing underneath what I am seeing, how can I make
it (the message box) appear on top?

Here's the code I just tried:

Private Sub cmb4SaveAll_click()
Dim CommonDialog3 As Dialog
Set CommonDialog3 = Dialogs(wdDialogFileSaveAs)
With CommonDialog3 'CindyM says show all msgs
Application.DisplayAlerts = wdAlertsAll
Application.ScreenUpdating = True
.Name = ""
If .Display = -1 Then
.Execute
.Update
ElseIf .Show = 0 Then
Exit Sub
End If
End With
End Sub
 
B

Bob S

I have the following code which works fine unless the filename already
exists, in which case it "freezes" and won't do anything, and I am forced to
cancel. How can I modify this code to save an already-existing filename?

Private Sub cmb4SaveAll_click()
Dim CommonDialog3 As Dialog
Set CommonDialog3 = Dialogs(wdDialogFileSaveAs)
On Error Resume Next
With CommonDialog3
.Name = ""
If .Show = 0 Then ' if cancel, exit sub
Exit Sub
End If
End With
End Sub

There was a post on the 11th titled something like "File Save Makes Me
Crazy" reporting non-saving of files. One person stated that the Show
method of wdDialogFileSaveAs was buggy in Word 2002, and if you
avoided that method the file would get saved, at the cost of the user
not seeing the dialog.

Bob S
 

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