cancel
Showing results for 
Search instead for 
Did you mean: 

[RESOLVED] VBScript to update Outlook custom.dic?

henderson1977
Grafter
Posts: 191
Registered: ‎31-07-2007

[RESOLVED] VBScript to update Outlook custom.dic?

Hi all
We have been asked to update the Outlook dictionary with a few additions on 1500+ users' machines.  I know the users could easily add the addition manually themselves when prompted but this is not an option. 
We need to run a script of some kind to automatically update the C:\Documents and Settings\%username%\Application Data\Microsoft\Proof\Custom.dic on all 1500+ machines.  We cannot replace the existing custom.dic because the users will lose their existing entries.
Any ideas please?
Huh
4 REPLIES 4
henderson1977
Grafter
Posts: 191
Registered: ‎31-07-2007

Re: Script updates to Outlook custom.dic?

I found a VBScript to add a custom dictionary to Word:-
Set objWord = CreateObject _
("Word.Application")
Set colDictionaries = _
objWord.CustomDictionaries
colDictionaries.Add "pm.dic"
objWord.Quit

This additional pm.dic works well in Word 2003 but it doesn't work for Outlook 2003 because Outlook only uses the default custom.dic.  We don't want to make Word the default email editor, so how can we add the additional entries to the custom.dic so that it works in Outlook 2003 as well please?  We may need a VBScript to open the custom.dic and append the additional entries but I'm no VB wiz?
TIA
Scott
henderson1977
Grafter
Posts: 191
Registered: ‎31-07-2007

Re: Update Outlook custom.dic?

The following VBscript allows me to create a new text file and add the word "DDI" into it:-
--------------
  Dim fso, tf
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set tf = fso.CreateTextFile("c:\misc\testfile.txt", True)
  ' Write a line with a newline character.
  tf.WriteLine("DDI")
  tf.Close
--------------
This is not quite what I need.  I need to add "DDI" and other words to the existing custom.dic file in each user's profile.
Any ideas please?
Thanks
Scott
henderson1977
Grafter
Posts: 191
Registered: ‎31-07-2007

Re: [RESOLVED] VBScript to update Outlook custom.dic?

Hi all
I found a VBscript and tweaked it to our specific requirements:-
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.5 - August 2005
' ---------------------------------------------------------------'
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText1, strText2, strText3
Dim objNetwork, strUser
' Obtain currently logged on username (equivalent to %username%)
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
strDirectory = "C:\Documents and Settings\" & strUser & "\Application Data\Microsoft\Proof"
strFile = "\custom.dic"
strText1 = "Test1"
strText2 = "Test2"
strText3 = "Test3"
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFolder = objFSO.CreateFolder(strDirectory)
    ' WScript.Echo "Just created " & strDirectory
End If
If objFSO.FileExists(strDirectory & strFile) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
    ' Wscript.Echo "Just created " & strDirectory & strFile
End If
set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)
' Writes all strText values every time you run this VBScript
objTextFile.WriteLine(strText1)
objTextFile.WriteLine(strText2)
objTextFile.WriteLine(strText3)
objTextFile.Close
' Bonus or cosmetic section to launch explorer to check file
If err.number = vbEmpty then
  Set objShell = CreateObject("WScript.Shell")
  objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If
WScript.Quit
' End of VBScript to write to a file with error-correcting Code

Hope this helps others!
Scott      Wink
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: [RESOLVED] VBScript to update Outlook custom.dic?

Nothing like doing your own donkey work Roll_eyes