Link to home
Start Free TrialLog in
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Office templates location(s) in relation to windows registry

I am trying to write a component of an add-in that will automatically downloads and save templates to the correct current folder for a user, even if the default has been changed by the user and/or IT Group Policy.

There are three issues I am facing.

PART 1 : Terminology and UI


It looks like Office 2013 introduced the content of Personal/Custom templates. This folder can be set by the user in File / Options / Save Regarding terminology:

User generated image
I have seen some users see the word  "Custom" while others see "Personal" in the backstage when accessing templates. My first question is why? Is it to do with the version of Office, 365, configuration or something else?

User generated imageUser generated image
Next, there seems to be a difference between UserTemplates and PersonalTemplates. Each appears to be located in the registry as follows:

UserTemplates:
HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\Common\General
Value Name : UserTemplates
Value Type : REG_SZ

Open in new window

PersonalTemplates:
HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\PowerPoint\Options
Value Name : PersonalTemplates
Value Type : REG_SZ

Open in new window


Neither appear to be set by default so I assume that the Office app will look in a default location if either/both are missing? If so, where is that stored?

PART 2 : Best approach to ascertain where to store templates


In order to determine if the "default" templates location has been changed, which registry keys should I be looking at for Office (more specifically PowerPoint) 2016, 2013, 2010 and 2007 and where should I actually store the templates (User/Personal)?

PART 3 : Charts folder


For 2013 at least, the default Charts (.crtx store) is in the Charts sub-folder of the personal templates path, e.g. %appdata%\Microsoft\Templates\Charts

Is this automatically derived by an Office app by suffixing the Charts folder to the personal templates path or is there a separate registry setting for it?
ASKER CERTIFIED SOLUTION
Avatar of Echo_S
Echo_S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jamie Garroch (MVP)

ASKER

Thanks Echo_S. based on the above pointers and other research, I've done this:

' Returns the locations for PowerPoint and Chart template folders
Public Sub GetTemplateFolders(Optional ByRef POTX As String, Optional ByRef CRTX As String)
  Dim oWScript As Object
  Set oWScript = CreateObject("WScript.Shell")
  On Error Resume Next ' To deal with non-existant registry keys
  Select Case Val(Application.Version)
    Case Is >= 15 ' e.g. 2013 onwards
      POTX = oWScript.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\PowerPoint\Options\PersonalTemplates")
      ' If it's not been defined, use the default
      If POTX = "" Then POTX = Environ("USERPROFILE") & "\Documents\Custom Office Templates\" Else If Not Right(POTX, 1) = "\" Then POTX = POTX & "\"
     
      CRTX = oWScript.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\Common\General\UserTemplates")
      ' If it's not been defined, use the default
      If CRTX = "" Then CRTX = Environ("APPDATA") & "\Microsoft\Templates\Charts\" Else CRTX = CRTX & IIf(Right(CRTX, 1) = "\", "Charts\", "\Charts\")
    Case Is < 15 ' e.g. 2010 and earlier
      POTX = oWScript.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\Common\General\UserTemplates")
      ' If it's not been defined, use the default
      If POTX = "" Then POTX = Environ("USERPROFILE") & "\Documents\Custom Office Templates\" Else If Not Right(POTX, 1) = "\" Then POTX = POTX & "\"
     
      CRTX = oWScript.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\Common\General\UserTemplates")
      ' If it's not been defined, use the default
      If CRTX = "" Then CRTX = Environ("APPDATA") & "\Microsoft\Templates\Charts\" Else CRTX = CRTX & IIf(Right(CRTX, 1) = "\", "Charts\", "\Charts\")
  End Select

I'll soon see if it works once it gets deployed on multiple machines!

Interesting exception you note to the new 2013/2016 scheme for blank.potx!
Yeah, the blank.potx thing is a bit odd. PPT's always looked for blank.potx in the %appdata% Templates folder, so that doesn't surprise me. What does surprise me is that putting that in the Custom (or Personal) folder doesn't do the trick.

They don't make it easy, do they?

Thanks for posting your findings. I know that will help someone somewhere sometime! ;-)