Re: Need help with MS Word 2004 languages and dictionaries
Re: Need help with MS Word 2004 languages and dictionaries
- Subject: Re: Need help with MS Word 2004 languages and dictionaries
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 02 May 2005 11:25:44 -0700
Oops, maybe I should start filing my various mailing lists into separate
folders. I'm sorry: I misread. Thanks for the correction.
Ok, you want to do this in AppleScript. Sorry.
You can use the long list of 'language ID' enumerations that are found in
various classes. Probably the most useful place is 'template', since you can
always get the 'attached template' of any document - usually that will be
Normal template. If you're starting off from a new document, you might want
to just assume the Normal template. As far as I know, there are no
differences as to which languages are available by AppleScript (or VBA) in
the various localized versions of Word. I might be wrong - I'll ask. But I
think that the only language IDs available by AppleScript are the ones you
see as enumerations on the Word AS dictionary. You can coerce each one 'as
string' to make your list, or - better - use the 'retrieve language' command
so you can present the list in the user's local language. I see where
'choose form list' still uses strings, not Unicode , even in Tiger (shame!).
so maybe that won't work, but
name local of (retrieve language (language ID of normal template))
gets me "English (US)" here. Using 'name' instead of 'name local' might be
a better idea to avoid the Unicode problem of 'choose from list'.
name of (retrieve language danish)
--> "Dansk"
name local of (retrieve language danish)
--> "Danish"
Use whichever you prefer. If the language is not installed (if that's
possible), you'd get an error. So to build your list - just in case some
languages really are not available locally - you could do something like:
tell application "Microsoft Word"
set languageList to {}
try
set end of languageList to name local of (retrieve language danish)
end try
try
set end of languageList to name local of (retrieve language german)
end try
-- etc. through every language ID
set chosenLanguage to item 1 of (choose from list languageList)
end tell
For your second question, I think it would be too risky to try to coerce the
string back to the language ID via 'run script', even using the 'name'
string rather than the 'name local'. Instead I think you just need to have a
separate list of every enumeration, and get the same list item as the
selected string is found to be from the languageList. A sort of lookup (you
could do it via a list of records too.) E.g.
tell application "Microsoft Word"
set languageList to {}
set languageIDList to {}
try
set end of languageList to name local of (retrieve language danish)
set end of languageIDList to danish -- will omit if previous line
errors
end try
try
set end of languageList to name local of (retrieve language german)
set end of languageIDList to german
end try
--etc, through every language ID
set chosenLanguage to item 1 of (choose from list languageList)
set theIndex to my CollectUniqueItemIndex(languageList, chosenLanguage)
set chosenLanguageID to item theIndex of languageIDList
end tell
to CollectUniqueItemIndex(theList, theItem)
set theIndex to 0
repeat with i from 1 to (count theList)
set aListMember to item i of theList
if aListMember = theItem then
set theIndex to i
exit repeat
end if
end repeat
return theIndex
end CollectUniqueItemIndex
--
Paul Berkowitz
> From: Richard Rönnbäck <email@hidden>
> Date: Mon, 02 May 2005 19:09:37 +0200
> To: AppleScript <email@hidden>
> Subject: RE: Need help with MS Word 2004 languages and dictionaries
>
> Oh, I thought this was the AppleScript list ;-)
>
> But I see your point, thanks for the advice, I will try to post the question
> there there too
>
> Thanks
>
> --
> Richard Rönnbäck
>
>
>> Från: Paul Berkowitz <email@hidden>
>> Datum: Mon, 02 May 2005 08:12:17 -0700
>> Till: AppleScript-Users <email@hidden>
>> Ämne: Re: Need help with MS Word 2004 languages and dictionaries
>>
>> This is the Entourage mailing list, Richard.
>>
>> You'll get really expert Word help on the Mac Word newsgroup:
>>
>> microsoft.public.mac.office.word
>>
>> The best way to access that is in a newsreader. You can do so in Entourage.
>> by clicking on the Microsoft News Server icon in the Folders list, entering
>> "mac.office" (no quotes) in the text filter box, selecting the newsgroup
>> above (NOT one with mac.office reversed - those are deprecated) and any
>> others you want listed there, and click Subscribe button. You'll then find
>> the mac word newsgroup listed under the server in the Folders list.
>>
>> --
>> Paul Berkowitz
>>
>>
>>> From: Richard Rönnbäck <email@hidden>
>>> Date: Mon, 02 May 2005 08:37:24 +0200
>>> To: AppleScript <email@hidden>
>>> Subject: Need help with MS Word 2004 languages and dictionaries
>>>
>>> I need to change applied language to text in rtf-files, using MS Word 2004,
>>> but I have run into two problems, that I am sure are very basic but I just
>>> don't get it.
>>>
>>> Ideally I would like the user to be able to select language from a list and
>>> then apply the chosen language to all text in the document. My two problems
>>> with this are:
>>>
>>> 1) How do I retrieve a list of names of available (installed) languages from
>>> the application itself? I could of course hardwire the list, but would
>>> really prefer to build it dynamically from the actual languages
>>>
>>> 2) If I a present a list of names (strings) to the user, how can I get MS
>>> Word to accept the string as a valid language, in other words, how do I go
>>> from a string to the language ID that MS Word require?
>>>
>>> Any help is much appreciated
>>>
>>>
>>> --
>>> Richard Rönnbäck
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Applescript-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>
>
> m
>>>
>>> This email sent to email@hidden
>>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Applescript-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
r
>> edband.net
>>
>> This email sent to email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden