Copy link to clipboard
Copied
I want to add a new, global spelling dictionary for dozens of users, without having to have each individual user add the dictionary..
So, I am looking for a JavaScript that would do the equivalent of:
Edit --> Preferences --> Spelling, clicking on Dictionary and adding a new dictionary with this specific path:
\\file_server\class_master\sitename\InDesign\Dictionary\Global Dictionary.udc
Any assistance would be greatly appreciated.
John,
Your mixing up "Windows" with "javascript on Windows"
When you type a file path in Windows explorer or use the path in VB or one of it's mutations then you can use the 'C:\John' notation.
However, when you use a javascript string to refer to the same file you have to use 'C:\\John' with a double \
This is because the \ symbol in javascript strings has a special meaning (escape) as such if you want it to be treated as a literal \ you need to use 2 of them, the alternative is to use '\x5c' i.e.
...Copy link to clipboard
Copied
Try this:
var path = "\\file_server\class_master\sitename\InDesign\Dictionary\Global Dictionary.udc"
var var lang = app.languagesWithVendors.itemByName("English: USA");
lang.addDictionaryPath (filePath);
Harbs
Copy link to clipboard
Copied
Not quite there.
On first try, got error message, "Illegal use of reserved word 'var'"
Determined that was from duplication of "var" at start of second line.
After removing one of the "var" entries on that line, tried again and got error message, "filePath is undefined."
Changed "(filePath") at end of third line to "(path)", tried again and that did not work.
Changed start of first line to "var filePath" and end of third line back to "(filePath)", tried again and got error message, "Cannot add dictionary path."
Here is the current version of the script that resulted in the "Cannot add dictionary path" error:
var filePath = "
brainworks.mindshift\data\bw_class-sci\class_master\SCHURZ\InDesign\Dictionary\GlobalDictionary.udc"
var lang = app.languagesWithVendors.itemByName("English: USA");
lang.addDictionaryPath (filePath);
Copy link to clipboard
Copied
Sorry for the typos.
It looks like you need colon notation on Mac for it to work. For example, the following works on my machine:
app.languagesWithVendors.itemByName("English: USA").addDictionaryPath ("Macintosh HD:Users:harbs:Desktop:dictionary.udc");
Copy link to clipboard
Copied
This is for Windows, not Mac.
Copy link to clipboard
Copied
Try importing it manually, and copying the exact path to the script.
Copy link to clipboard
Copied
I have tried again with the desired dictionary simply in a subfolder of the C drive, not on the file server as ultimately desired, and still get the error, "Cannot add dictionary path"
The JavaScript file right now has only this one line, similar to the one line you showed for your Mac:
app.languagesWithVendors.itemByName("English: USA").addDictionaryPath ("C:\4JohnW\GlobalDictionary.udc");
Copy link to clipboard
Copied
You need to escape your path using \\ or use /.
app.languagesWithVendors.itemByName("English: USA").addDictionaryPath ("C:\\4JohnW\\GlobalDictionary.udc");
app.languagesWithVendors.itemByName("English: USA").addDictionaryPath ("C:/4JohnW/GlobalDictionary.udc");
The / would work on the Mac too.
Copy link to clipboard
Copied
In Windows, a double slash indicates a server or computer name, such as
myfileserver<file:///
myfileserver>, and a single slash is used for subfolders, such as
myfileserver\shareddrive\subfolder<file:///
myfileserver\shareddrive\subfolder>. There is no slash of any kind before the drive letter of the computer on which the folder resides, thus C:\JohnW.
In fact, if you specify a dictionary manually that is on the C drive, the list of dictionaries in InDesign shows C:\JohnW.
I will try the forward slash in hopes that might make a difference.
Copy link to clipboard
Copied
John,
Your mixing up "Windows" with "javascript on Windows"
When you type a file path in Windows explorer or use the path in VB or one of it's mutations then you can use the 'C:\John' notation.
However, when you use a javascript string to refer to the same file you have to use 'C:\\John' with a double \
This is because the \ symbol in javascript strings has a special meaning (escape) as such if you want it to be treated as a literal \ you need to use 2 of them, the alternative is to use '\x5c' i.e. it's ascii code or '\u005c' it's unicode '\\' is easier.
This is a general all platform rule that does not relate specifically to file paths, nor does it relate specifically will InDesign.
Trevor
Copy link to clipboard
Copied
Thank you, Trevor. After a little more trial and error, I finally got the path to work as desired, which is to a subfolder of a file server, rather than the local computer.
Copy link to clipboard
Copied
Hi John
Can you mark either the answers as correct and helpful.
Thanks
Trevor
Copy link to clipboard
Copied