如何获取其他用户的 MS Word 模板目录?

发布于 2024-08-30 04:08:59 字数 227 浏览 1 评论 0原文

我使用以下代码来获取 Word 存储其模板的路径:

WordTemplatePath:=WordApp.Options.DefaultFilePath[$00000002];

问题是这会返回实际登录用户的路径。

有没有办法获取同一 Windows 实例的另一个用户的路径?

我需要它,以便我的安装程序也可以为其他用户安装我的程序使用的模板。

I'm using the following code to get the path where Word stores its templates:

WordTemplatePath:=WordApp.Options.DefaultFilePath[$00000002];

The problem is that this returns the path for the actual, logged-in user.

Is there a way to get the path for another user of the same Windows instance?

I need it so my installer program can install the templates used by my program for other users as well.

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

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

发布评论

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

评论(1

む无字情书 2024-09-06 04:08:59

这种方法效果不会太好。通常,用户无权访问其他用户的配置文件文件夹,并且每个用户的“模板”文件夹位于他们的配置文件中。

一般来说,如果您需要为所有用户安装模板,最好将其放在“STARTUP”文件夹中,或者可能放在“WorkGroup Templates”文件夹中。

或者,您可能需要管理员权限才能安装,然后进行扫描,但即便如此,用户也可能(尽管不太可能)更改了模板文件夹的路径,因此您可以对其进行硬连线,但您必须扫描 Word 的注册表为每个用户正确完成该工作的设置。这可不是什么值得深思的美好事情。

您只是更新自己的模板吗?或者您想要扫描并修改用户为自己创建的所有模板?如果是后者,您可以将该逻辑移至您的插件中,并使其成为每次用户加载时调用的函数(或者给他们一个按钮以强制扫描)。

That approach isn't going to work too well. Typically, users won't have access to other user's profile folders and the "templates" folder for each user is located in they're profile.

Generally, if you need a template installed for all users, it's best to put it in the word STARTUP folder, or possibly in the "WorkGroup Templates" folder.

Alternately, you could require admin rights for the install and then scan, but even then, its possible (though unlikely) that users could have changed the path to their templates folder and so you can hardwire it, you'd have to scan Word's registry settings for each user to do that job right. Not a pretty thing to contemplate.

Are you just updating you're own templates? or are you wanting to scan and modify all the templates that a user has created for themselves? If the latter, you might instead move that logic into your addin and make it a function that is called each time the user loads up (or maybe give them a button to press to force the scan).

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