在 Word 中,以编程方式打开新文档对话框

发布于 2024-08-27 23:58:47 字数 406 浏览 1 评论 0原文

我正在寻找一种在 Word 2007 中以编程方式打开“新建文档”对话框的方法。它与选择 File->New 时得到的对话框相同。您还可以使用 FileNew 宏或“新建...”菜单命令打开它。但是,我一直无法找到一种以编程方式执行此操作的方法。

我已经尝试过:

Application.Run MacroName:="FileNew"

and

Dialogs(wdDialogFileNew).Show

and

CommandBars.FindControl(ID:=5746).Execute

但这两者都会打开旧对话框,而不是 word 2007 使用的新对话框。

I am looking for a way to programatically open the "New Document" dialog in Word 2007. It is the same one you get when you select File->New . You can also open it using the FileNew macro or the "New..." menu command. However, I have been unable to find a way to do this programmatically.

I have tried:

Application.Run MacroName:="FileNew"

and

Dialogs(wdDialogFileNew).Show

and

CommandBars.FindControl(ID:=5746).Execute

but both of these open the old dialog, not the new one that word 2007 uses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傻比既视感 2024-09-03 23:58:47

如果存在用于打开该对话框的“真实”VBA 命令,我找不到它。然而,我确实通过一些快速谷歌搜索发现了这个完全蹩脚的解决方法:

SendKeys "%"
SendKeys "F"
SendKeys "N"

它确实可以满足你的要求!在这里找到它 http://www .eggheadcafe.com/software/aspnet/32228837/new-file-dialog-in-word-2.aspx

If a 'real' VBA command exists for open that dialog, I can't find it. However, I did find this utterly lame workaround via some quick googling:

SendKeys "%"
SendKeys "F"
SendKeys "N"

It does what you want though! Found it here http://www.eggheadcafe.com/software/aspnet/32228837/new-file-dialog-in-word-2.aspx

情痴 2024-09-03 23:58:47

您可以获取按钮的命令 ID 并执行它吗?

Dim c As CommandBarControl
Set c = CommandBars.FindControl(ID:=18)
c.Execute

控件 ID 18 是“新建...”按钮的字应用程序 ID。

You could get the Command ID for the button and execute it?

Dim c As CommandBarControl
Set c = CommandBars.FindControl(ID:=18)
c.Execute

Control ID 18 is the word application ID for the New... button.

心奴独伤 2024-09-03 23:58:47

我认为你可以只使用:

Documents.Add

不带任何参数。

I think that you can just use:

Documents.Add

without any parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文