Archive: Installing Office (MS Word) Templates


Installing Office (MS Word) Templates
I have a few MS Word templates (.dot files) which I need to distribute. I would like to install these into the user's template folder so that when they click on "New" within Word these will appear for them to choose. I can access the templates path using VBScript, but being a newbie to NSIS I'm unsure how to do this with an NSIS script...

Is there a simple way to determine the user's template folder and copy the files there? Seems like a fairly easy task, but I'm having some problems figuring out the best way.

Thank you in advance for your help!

-pcraider


First. Detect the hole path for the templetes directory.
This you can use it with "ReadRegStr" instruction.
In the Registry this is its root of Office
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office


I checked the registry key, but there doesn't appear to be any "templates" path listed there. Is there any way to use/translate VBScript into an NSIS script? The code I was able to write to access the templates path is as follows:

Dim o
Dim sPath
Set o = CreateObject("Word.Application")
sPath = o.Templates(1).FullName
sPath = Mid(sPath, 1, InStrRev(sPath, "\") - 1)
o.Quit
Set o = Nothing

Where sPath is the path to the templates folder.


You can't convert this VBScript code to NSIS. It must be somewhere in the registry, try to search using Google.


I wish it were that straight-foward. In everything I've found, it appears the templates folder location is varied based on OS/Office version, etc. (e.g. WD2000: General Questions and Answers About the Location of Word 2000 Templates)

Also, it is possible the user has customized the path to their templates folder (in which case this DOES appear in the registry). I really can't believe it is this difficult to deploy custom templates...


To get the shell folders, check http://nsis.sourceforge.net/archive/...e.php?pageid=6


Joost,

Thank you... that may work!


Office Templates
I'm by no means no expert in NSIS, but i have been doing the following:

I think it's much easier to use the Workgrouptemplates setting - this item is designed for using templates besides the ones included with office - and it's much easier to copy to, since u can have them in your own directory

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\General

but again the problem is that according to which version of office is used, the \10.0\ changes... This is how i did it in my template installer (Where i copy the templates to a specified directory)

The problem is i have to use a setting for each version of office that might be installed on my end-users

If any of you guys in this forum know how to make it simpler, please let me know...

If only the Office WorkgroupDir RegSetting was working as a shellfolder!

Here's a part of my installerscript:

;Setup workgroup templatedir for Office
EnumRegKey $1 HKCU "Software\Microsoft\Office\8.0" 1
IfErrors Found1
Goto NextKey1
Found1:
WriteRegStr HKCU "Software\Microsoft\Office\8.0\Common\General" "SharedTemplates" "c:\OwnTemplates\"
WriteRegStr HKCU "Software\Microsoft\Office\8.0\Common\FileNew\SharedTemplates" "" "c:\OwnTemplates\"
Goto EndOffPaths
Nextkey1:
EnumRegKey $1 HKCU "Software\Microsoft\Office\9.0" 1
IfErrors Found2
Goto NextKey2
Found2:
WriteRegStr HKCU "Software\Microsoft\Office\9.0\Common\General" "SharedTemplates" "c:\OwnTemplates\"
Goto EndOffPaths
Nextkey2:
EnumRegKey $1 HKCU "Software\Microsoft\Office\10.0" 1
IfErrors Found3
Goto NextKey3
Found3:
WriteRegStr HKCU "Software\Microsoft\Office\10.0\Common\General" "SharedTemplates" "c:\OwnTemplates\"
WriteRegStr HKCU "Software\Microsoft\Office\10.0\Word\Security" "Level" "1"
Goto EndOffPaths
Nextkey3:
EnumRegKey $1 HKCU "Software\Microsoft\Office\11.0" 1
IfErrors Found4
Goto EndOffPaths
Found4:
WriteRegStr HKCU "Software\Microsoft\Office\11.0Common\General" "SharedTemplates" "c:\OwnTemplates\"
; WriteRegStr HKCU "Software\Microsoft\Office\10.0\Word\Security" "Level" "1"
Goto EndOffPaths
EndOffPaths:


The above script part is for Word only ! I have script part for Excel as well, and for copying .DOT files to have them autostart in Word/Excel (For macro functions in templates for instance):hang: