How to get MS Word templates directory for another user?
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 ther开发者_运维问答e 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.
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).
精彩评论