I'm using a script to place templates and themes (for Office) in the Templates folder. I'm using the "SpecialFolders" call. I thought I had it right by using this:
whshell.SpecialFolders("Templates")
But I'm getting:
C:\Users\myUserID\AppData\Roaming\Microsoft\Windows\Templates
and no the one I need which is this one...
C:\Users\myUserID\AppData\Roaming\Microsoft\Templates
Is there a call that gives me the right (last) path?
SpecialFolders
-
- BronzeLounger
- Posts: 1258
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SpecialFolders
In Word:
Application.Options.DefaultFilePath(wdUserTemplatesPath)
In Excel:
Application.TemplatesPath
Application.Options.DefaultFilePath(wdUserTemplatesPath)
In Excel:
Application.TemplatesPath
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1258
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: SpecialFolders
Yep, this is a VBS script file however (I need to copy some template files etc. to users), so how do I do it there?
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SpecialFolders
You could use Automation:
CreateObject("Excel.Application").TemplatesPath
CreateObject("Excel.Application").TemplatesPath
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1258
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: SpecialFolders
Ended up using this:
WSHShell.SpecialFolders("AppData") & "\Microsoft\Templates"
WSHShell.SpecialFolders("AppData") & "\Microsoft\Templates"
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SpecialFolders
That will only work if the user hasn't changed the location of the user templates folder. It can be changed in the Options dialog for Word (Word 97-2003: File Locations tab; Word 2007-2010: Advanced, File Locations button in the General section).
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1258
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: SpecialFolders
OK, but using Excel to get a path seems like overkill; is there no 'simple' way in VBScript then??
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SpecialFolders
Problem is that if the user hasn't changed the path, the registry entry just says "Templates", which tells Office to look in the default location. If the user has changed it, the registry entry contains the full path. So reading the registry entry is not a straightforward solution.
It is HKEY_CURRENT_USER\Software\Microsoft\Office\n.0\Common\General\Templates, by the way, where n is the internal Office version number (8 = Office 97, ..., 14 = Office 2010, no version 13).
It is HKEY_CURRENT_USER\Software\Microsoft\Office\n.0\Common\General\Templates, by the way, where n is the internal Office version number (8 = Office 97, ..., 14 = Office 2010, no version 13).
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: SpecialFolders
I suppose you could consider reading the Registry (RegRead?) for the templates' paths, although you may find that you don't have access to the users' registry - discussed here.
Also, the registry key won't exist if the default location(s) haven't been changed. In which case you would need to construct the default location, inserting the user's name.
Something like:
But refer to Hans' recent post as well. Andy.
Also, the registry key won't exist if the default location(s) haven't been changed. In which case you would need to construct the default location, inserting the user's name.
Something like:
Code: Select all
‘HKEY_CURRENT_USER = HKCU
‘HKEY_LOCAL_MACHINE = HKLM
‘HKEY_CLASSES_ROOT = HKCR
‘HKEY_USERS = HKEY_USERS
‘HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG
Dim objRegistry, Key, ReadReg
Set objRegistry = CreateObject(â€Wscript.Shellâ€)
Key = objRegistry.RegRead("HKCU\Software\Microsoft\Office\12.0\Common\General\UserTemplates")
ReadReg = Key
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.