COURSE of the MONTH

msoFileDialogSaveAs

The following code is part of a custom saving vba macro used in word :

Private Sub ShowFileSaveAsDialog(ByVal strDir As String)

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
.InitialFileName = strDir
If .Show = CANCEL_PRESSED Then
Else
.Execute
End If
End With
Set fd = Nothing

End Sub

The saveas dialog box is shown, .execute method actually does the save. Works right? Well, not quite. If one document is open, it works perfectly. However, with more than one document open, Word seems to determine which document is to be saved at random, regardless of which was active and had focus. Very frustrating when a user names a file one thing and then finds out it saved a copy of something else. Anyone know of a way to force it to save the correct active document?

It seems that I do not have FileDialog on my system.
Can you please check your references as to which library this function comes from?

My guess is that the problem is that you are using the Application object to call FileDialog.
If this event also exists for a document object, (very probably so), then I would assume that changing your set statement accordingly should solve your problem

Dabas

0

CleanupPingCommented: 2003-07-11

haz43:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
Experts: Post your closing recommendations! Who deserves points here?