Link to home
Start Free TrialLog in
Avatar of prologic08
prologic08

asked on

VBS to append to the default.dic dictionary file

I am trying to create a VBS (no experience btw) to append to the default.dic file which is where you add words to the dictionary when you are in IE and possibly other apps.

The VBS will work if the default.dic file is created from scratch as a text file and renaming it to default.dic...BUT..once I start adding words to the dic file from IE, it changes the encoding. When I run the VBS below after adding words through IE, it adds this:

User generated image
Instead of this:
Test1
Test2

I want to make sure that if any users have already added words to the file that it will only add the extra words and not create a new file or delete what is already there.

Here is the code:
Const ForAppending = 8
Set objNetwork = CreateObject("WScript.Network")
strFolder = "C:\Users\" & objNetwork.UserName & "\AppData\Roaming\Microsoft\Spelling\en-US"
strFile = "default.dic"
strPath = strFolder & "\" & strFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strPath, ForAppending)

objFile.WriteLine
objFile.WriteLine "Test1"
objFile.WriteLine "Test2"

objFile.Close

Open in new window


The file is located here:
C:\Users\%username%\AppData\Roaming\Microsoft\Spelling\en-US
Avatar of Rgonzo1971
Rgonzo1971

Hi,

to be sure if the word is not already in the dic

pls try to use ( with reference to Excel)

Function SpellCheck(SomeWord As String)
SpellCheck = Application.CheckSpelling(SomeWord)
End Function

Regards
Avatar of prologic08

ASKER

Encoding is UTF-16 LE Plaintext. I just need to figure out how to write new text from vbs this way.
ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
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
Thanks ltlbear! This worked perfect! I appreciate your help with this. I was trying to figure out what the encoding was but didn't realize that I just had to look under Encoding within Notepad++! I learned something new. Thanks again!!
I had another request if possible. The script will append to a dic file but if the dic file does not exist, it will not create a new one. Can we add code to create the dic file with the added words if no dic file exists? I can create a new question if requested. Thank you!