带模板的 Word 2010 自动化

发布于 2024-10-04 03:09:54 字数 228 浏览 4 评论 0原文

我在 Delphi 中编写了几个使用 Word 自动化的应用程序。这些程序都使用存储在目录中的模板。在 Word 2010 之前的版本中,可以在工具|选项|文件位置中定义模板的位置;程序将传递模板的名称,Word 将知道在哪里可以找到它。

我的客户现在已迁移到 Office 2010,因此,当我的程序启动 Word 时找不到该模板。我在 Word 中找不到类似的对话框,可以在其中定义模板的默认目录。如何定义这样一个目录呢?

I have written several applications in Delphi which use Word automation. The programs all use templates which are stored in a directory. In pre-2010 versions of Word, one would define the location of the templates in tools|options|file locations; the programs would pass the name of the template and Word would know where to find it.

My client has now moved to Office 2010, and as a result, Word cannot find the template when started by my programs. I haven't been able to find a similar dialog box in Word in which I can define the default directory for templates. How does one define such a directory?

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

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

发布评论

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

评论(4

零時差 2024-10-11 03:09:54

单击文件 |选项|高级|文件位置,您将获得与旧版本相同的对话框alt text

Click File | Options | Advanced | File Locations and you get the same dialog as in older verionsalt text

弥枳 2024-10-11 03:09:54

您可能更愿意使用 /t 开关调用 Word,而不是强制用户配置 Word 来定义模板的位置。

/ttemplatename 使用基于普通模板以外的模板的新文档启动 Word。

>"%programfiles%\Microsoft Office\Office14\winword.exe" /t"c:\MYTEMPLATES\mytemplate.dotx"

Instead of forcing your user to configure Word to define the location of templates, you might prefer to invoke word using /t switch.

/ttemplatename starts Word with a new document based on a template other than the Normal template.

>"%programfiles%\Microsoft Office\Office14\winword.exe" /t"c:\MYTEMPLATES\mytemplate.dotx"
偏闹i 2024-10-11 03:09:54

创建新文档时不能只指定完整路径吗?为什么要依赖用户甚至可能更改的设置?将模板放在您自己的文件夹中并指定完整路径。

Can't you just specify the full path when creating a new document? Why rely on a settings that possibly can even be changed by the user? Put your templates in your own folder and specify the full path.

墨洒年华 2024-10-11 03:09:54

Word 的路径配置已存储

获取 USER 模板文件夹

您可以通过Word.Application.Options.DefaultFilePath(WdDefaultFilePath.wdUserTemplatesPath)

(该属性还有其他选项)。

据我所知,模板加载规则从2007年到2010年没有改变。

一般来说,如果您的插件需要加载模板,您应该指定模板的完整路径和文件名,但是您可以获取通过上述典型的用户路径。

另一方面,如果将模板安装到 WORD\STARTUP 中,word 会自动加载它。但这可能不是您需要/想要的。

最后,如果您的模板不/不应该更改,最好将其保留在 PROGRAM FILES\appname 文件夹中并从那里加载。

一般来说,+要求+用户更改Word中的文件位置(或以编程方式更改它)是一个坏主意,因为很多人都不知道,而那些确实不希望插件自动更改这些设置的人!

Word's paths configuration are stored

You can get the USER template folder via

Word.Application.Options.DefaultFilePath(WdDefaultFilePath.wdUserTemplatesPath)

(there are others options for that property too).

As far as I can tell, the template loading rules haven't changed from 2007 to 2010.

Generally speaking, if your add in needs to load a template, you should specify the FULL path and file name to the template, but you can get the typical user path via the above.

On the other hand, if you install the template into WORD\STARTUP, word will automatically load it. that may not be what you need/want, though.

Finally, if your template doesn't/shouldn't change, it might be better to leave it in your PROGRAM FILES\appname folder and load it from there.

Generally speaking, +requiring+ users to change the FILE LOCATIONS in word (or changing it programmatically) is a bad idea, just because so many people wouldn't have a clue, and those that do definitely DO NOT want addins changing those settings automatically!

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