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.
  1. 'Restore Custom.dic  
  2. Option Explicit  
  3.   
  4. dim objFSO, objShell, objFile, objFolder  
  5. dim AppData  
  6. dim OldProofPath, NewProofPath  
  7.   
  8.   
  9. Set objFSO    = CreateObject("Scripting.FileSystemObject")  
  10. Set objShell  = CreateObject( "WScript.Shell" )  
  11.   
  12. AppData = objShell.ExpandEnvironmentStrings("%APPDATA%")  
  13.   
  14. OldProofPath = Appdata &"\Microsoft\Proof\"  
  15. NewProofPath = Appdata &"\Microsoft\UProof"  
  16.   
  17.   
  18. '*********************************************************************************************'  
  19. 'First create Folder if the folder doesn't exists  
  20. If Not objFSO.FolderExists (NewProofPath) Then  
  21.   objFSO.CreateFolder NewProofPath  
  22. End If  
  23. '*********************************************************************************************'  
  24.   
  25. '*********************************************************************************************'  
  26. Set objFolder = objFSO.GetFolder(OldProofPath)  
  27. 'If source folder does not exists...dont copy'  
  28. If objFSO.FolderExists(OldProofPath) Then  
  29.   For Each objFile In objFolder.Files   
  30.     'Copy all files with DIC extension'  
  31.     If Right(objFile.Name,3) = "DIC" Then  
  32.       objFile.Copy NewProofPath & "\" & objFile.Name  
  33.     End If  
  34.   Next  
  35. End If  
  36. '*********************************************************************************************'  
  37.   
  38. Set objFile = Nothing  
  39. Set objFSO = Nothing  
  40. Set objFolder = Nothing  

No comments: