Link to home
Start Free TrialLog in
Avatar of haz43
haz43

asked on

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?
Avatar of haz43
haz43

ASKER

never mind figured it out, the best solution is to use the word dialogs, MUCH faster too.

...
    With Dialogs(wdDialogFilePrint)
        ...
        .Execute
    End With
...
Avatar of haz43

ASKER

oops i meant

Private Sub ShowFileSaveAsDialog(ByVal strDir As String)
   
    With Dialogs(wdDialogFileSaveAs)
        .Name = strDir
        .Show
    End With
   
End Sub

lol wrong macro
I have Word 2000 and tried to run you macro.

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
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?
Avatar of DanRollins
haz43, an EE Moderator will delete this for you.
Moderator, my recommended disposition is:

    DELETE this question (refund points).

DanRollins -- EE database cleanup volunteer
Moderator:
Disagree.
Question was answered. Or at least there was an attempt to reach an answer.
Either Points to Dabas or PAQ/NO Refund

Dabas
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial