Word VBA - How to set the default save path?

3.3k views Asked by At

When the following code is executed it changes the directory of the save as dialog and shows the Save dialog,

With Dialogs(wdDialogFileSaveAs)
    .Name = "c:\newfolder\"
    .Show
End With

And the following code changes the default directory of the open dialog and shows the Open dialog,

  ChangeFileOpenDirectory "c:\newfolder\"
  Options.DefaultFilePath(wdDocumentsPath) = CurDir
  With Dialogs(wdDialogFileOpen)
     .Show
  End With

However, what I want to achieve is when the user clicks the Save or Save As icon on MS-Word it always needs to show the specific directory ("c:\newfolder\"). The above codes does not get executed when the Save or Save As icon clicked. I tried adding the code to the DocumentBeforeSave event but that shows the Save As dialog twice.

So, how to make MS-Word always so specific folder in Save dialog when the Save icon is clicked?

1

There are 1 answers

0
Egres On

You can add the code to the DocumentBeforeSave event. It has ref parameter Cancel. After you display your dialog, you set

Cancel = True 

This will cancel the following events so only your dialog is displayed.