Passwords not saved when calling FileSaveAs dialog from VBA

Article contributed by Ibby

If you call the FileSaveAs dialog (Word 97) with the following code:


the passwords entered under Options – Password to Open, Password to Modify do not stick.

There are two workarounds, depending on whether you need to change the settings in the dialog via code:


CommandBars.FindControl(ID:=748, Visible:=False).Execute


Dim strFileName As String

With Dialogs(wdDialogFileSaveAs)
    If .Display = -1 Then
        strFileName = .Name
        .Name = strFileName
    End If
End With