【问题标题】:Word VBA - How to set the default save path?Word VBA - 如何设置默认保存路径?
【发布时间】:2015-12-17 21:36:52
【问题描述】:

执行以下代码时,它会更改另存为对话框的目录并显示保存对话框,

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

以下代码更改了打开对话框的默认目录并显示了打开对话框,

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

但是,我想要实现的是当用户单击 MS-Word 上的“保存”或“另存为”图标时,它总是需要显示特定目录(“c:\newfolder\”)。单击“保存”或“另存为”图标时,不会执行上述代码。我尝试将代码添加到DocumentBeforeSave event,但这会显示“另存为”对话框两次。

那么,当单击“保存”图标时,如何使 MS-Word 在“保存”对话框中始终如此特定的文件夹?

【问题讨论】:

    标签: vba default ms-word savefiledialog


    【解决方案1】:

    您可以将代码添加到 DocumentBeforeSave 事件。它有 ref 参数 Cancel。显示对话框后,设置

    Cancel = True 
    

    这将取消以下事件,因此只显示您的对话框。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-25
      • 2017-05-02
      • 1970-01-01
      • 2019-03-26
      • 2012-01-21
      • 2021-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多