I’m actually doing this from Access, but the same problem comes up with Word VBA so I’ve posted it here.
I want to create the document programmatically, but then give the user the opportunity to specify the save as name and location. This code works fine in two cases: Cancel is trapped correctly and if they specify a new name it works. But if they specify an existing name (to overwrite it), the dialog box doesn’t release control – it stays ‘stuck’ in the .Display method.
Is this a Word bug?
Sub testWordSaveAsDialog() Dim wd As Word.Application Dim doc As Word.Document Dim vFileSaveName As Variant Set wd = New Word.Application Set doc = wd.Documents.Add With doc Dim myDialog As Dialog Set myDialog = wd.Dialogs(wdDialogFileSaveAs) If myDialog.Display = 0 Then 'Cancel MsgBox "File save cancelled" .Close SaveChanges:=wdDoNotSaveChanges Else 'Save vFileSaveName = myDialog.Name .SaveAs vFileSaveName MsgBox "File saved as: " & vFileSaveName .Close End If End With wd.Quit Set wd = Nothing End Sub