3/02/2008

Office 2007: Automatically restore custom.dic

The next file to restore automatically, when migrating to Office 2007 is the custom.dic file. It contains all user self-defined words.
The Problem is that the directory for .dic files changes in Office 2007. So the following Script can be implemented in your Logon Script.
It creates the neccesary folder UProof, which is only available when Word is started the first time and then copies all .dic files from the old directory into the new UProof folder.

'Restore Custom.dic
Option Explicit

dim objFSO, objShell, objFile, objFolder
dim AppData
dim OldProofPath, NewProofPath


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

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

OldProofPath = Appdata &"\Microsoft\Proof\"
NewProofPath = Appdata &"\Microsoft\UProof"


'*********************************************************************************************'
'First create Folder if the folder doesn't exists
If Not objFSO.FolderExists (NewProofPath) Then
objFSO.CreateFolder NewProofPath
End If
'*********************************************************************************************'

'*********************************************************************************************'
Set objFolder = objFSO.GetFolder(OldProofPath)
'If source folder does not exists...dont copy'
If objFSO.FolderExists(OldProofPath) Then
For Each objFile In objFolder.Files
'Copy all files with DIC extension'
If Right(objFile.Name,3) = "DIC" Then
objFile.Copy NewProofPath & "\" & objFile.Name
End If
Next
End If
'*********************************************************************************************'

Set objFile = Nothing
Set objFSO = Nothing
Set objFolder = Nothing

No comments: