简体   繁体   English

如何使用 VBA 或 AppleScript 在 MS Word 中打开显示 SharePoint 在线位置的“另存为”对话框?

[英]How to open a Save As dialog in MS Word showing SharePoint Online Locations by using VBA or AppleScript?

I have a Word Template containing VBA in a content type on SharePoint online.我有一个 Word 模板,其中包含 VBA 在线 SharePoint 的内容类型。 When a new document is created based on this content type Word desktop starts and VBA opens a dialog.当基于此内容类型创建新文档时,Word 桌面启动并且 VBA 打开一个对话框。 The user can enter some values in the dialog and click on a custom Save button.用户可以在对话框中输入一些值,然后单击自定义保存按钮。 The save button opens a Save As dialog in Word containing a filename derived from the user input.保存按钮会在 Word 中打开一个“另存为”对话框,其中包含源自用户输入的文件名。 The new document needs to be saved in the SharePoint online library where it was created.新文档需要保存在创建它的 SharePoint 在线库中。

In Word 2016 on MacOS you can open a Save As dialog by using VBA or AppleScript.在 MacOS 上的 Word 2016 中,您可以使用 VBA 或 AppleScript 打开“另存为”对话框。 I have tried the following code:我尝试了以下代码:

VBA VBA

With Application.Dialogs(wdDialogFileSaveAs)
    .Name = " testdoc.docx"
    .Show
End With

AppleScript AppleScript

tell application "Microsoft Word"
    activate
    set tmpDialog to get dialog dialog file save as
    display Word dialog tmpDialog
end tell

But this code opens a dialog showing only local storage options.但是此代码会打开一个仅显示本地存储选项的对话框。 See the print screen below.请参阅下面的打印屏幕。 在此处输入图像描述

What I need is the following dialog opened by code.我需要的是由代码打开的以下对话框。 在此处输入图像描述

This is the dialog when you manually click Save As in Word.这是您在 Word 中手动单击另存为时的对话框。

How can you open this Word dialog by using VBA or AppleScript?如何使用 VBA 或 AppleScript 打开此 Word 对话框?

To get to the dialog you are showing as your goal, it currently has to be accessed using the Online Locations button from the Word SaveAs dialog.要访问您作为目标显示的对话框,当前必须使用 Word SaveAs 对话框中的 Online Locations 按钮访问它。 That is if in Word > Preferences > Save... the property of Turn On AutoSave by Default is marked.也就是说,如果在 Word > Preferences > Save... 中标记了默认情况下打开 AutoSave 的属性。

However, I don't see the Online Locations button on the clip of the dialog you have shared.但是,我在您共享的对话框的剪辑上看不到“在线位置”按钮。 So... go to Word > Preferences > Save and clear the checkbox on the AutoSave by Default setting, then shutdown, restart, and try Word again.所以... go 到 Word > 首选项 > 保存并清除默认自动保存设置上的复选框,然后关闭、重新启动并再次尝试 Word。 That process will force Word to save your new Save setting.该过程将强制 Word 保存新的保存设置。

I don't know if this behavior is by design or is a bug, but I have reported it to Microsoft as being at a minimum, confusing.我不知道这种行为是设计使然还是错误,但我已向 Microsoft 报告它至少是令人困惑的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM