3/01/2008

Office 2007: Automatically restore AutoText entries from normal.dot

As you maybe know, there seems to be no possibility to automatically restore AutoText entries from previous Office versions to Office 2007.
Microsoft released a Workaround how to restore the AutoText entries from your normal.dot to Office 2007.
The trick is to copy the old normal.dot into one of the following folders:
%APPDATA%\Microsoft\Document Building Blocks\{Language ID}
or
%APPDATA%\Microsoft\Word\STARTUP
See also Microsoft article: http://technet2.microsoft.com/Office/en-us/library/ca7d3d97-6970-45c6-9b05-6a64cf1fbe711033.mspx?mfr=true

I see two problems in this Workaround:
1. I don't trust the STARTUP folder when i only wanna restore the AutoText entries, so i prefer the Document Building Blocks\{Language ID} folder
2. If you want to copy the normal.dot automatically for example with your Logon Script to this folder when the user logs on the first time, you can't copy the file, because the folder Document Building Blocks\{Language ID} only exists when Word is started the first time.

So....i wrote a script, which can be added to your Logonscript
The Script first creates the required folder and then copies the file!


'Restore AutoText entries from normal.dot
Option Explicit

dim objFSO, objShell
dim AppData
dim OldTemplatePath, NewTemplatePath, OldTemplate, NewTemplate
dim LanguageID

LanguageID = "1033"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject( "WScript.Shell" )

AppData = objShell.ExpandEnvironmentStrings("%APPDATA%")

'*********************************************************************************************'
'First create Folder if Word was not started yet'
If Not objFSO.FolderExists (AppData &"\Microsoft\Document Building Blocks\" &LanguageID) Then
objFSO.CreateFolder AppData &"\Microsoft\Document Building Blocks\"
objFSO.CreateFolder AppData &"\Microsoft\Document Building Blocks\" &LanguageID
End If
'*********************************************************************************************'

'*********************************************************************************************'
'Define office template paths here'
'OldTemplate = "normal10.dot" 'If languages match the file is renamed (OfficeXP)
'OldTemplate = "normal11.dot" 'If languages match the file is renamed (Office2003)
OldTemplate = "Normal.dot"
NewTemplate = "AutoText.dot"

'OldTemplatePath = AppData &"\Microsoft\Vorlagen\" german folder
OldTemplatePath = AppData &"\Microsoft\Templates\"

'NewTemplatePath = AppData &"\Microsoft\Word\STARTUP\"
NewTemplatePath = AppData &"\Microsoft\Document Building Blocks\" &LanguageID &"\"
'*********************************************************************************************'


'*********************************************************************************************'
'Determine if the old template exists'
If objFSO.FileExists(OldTemplatePath &OldTemplate) then
'Determine if the new template already exists'
If Not objFSO.FileExists(NewTemplatePath &OldTemplate) then
objFSO.CopyFile OldTemplatePath &OldTemplate, NewTemplatePath &NewTemplate
End If
End If
'*********************************************************************************************'

2 comments:

Heinz P. Lohfeldt said...

Great approach. But I have another problem: I'm using Office 2007 on two computers - one with Windows Vista, the other one with XP. Now: How can I transport my long list of entries from one machine to the other? Thanks for some help. Heinz P. Lohfeldt in Hamburg, Germany. - lohfeldt@gmx.de

merowinger said...

Hi, could you please explain more detailed? What do you mean with "long list"?