Article View: adobe.scripting.indesign
Article #16988Re: Getting FontName from FindPreferences dialog
From: Olav Kvern
Date: Thu, 10 Jul 2003 06:32
Date: Thu, 10 Jul 2003 06:32
40 lines
2247 bytes
2247 bytes
Robin--
This actually looks like a bug. When you set the font using the user interface, the scripting system does not pick up the font, but, instead, returns the Nothing enum (as if the font were undefined). If you set the font explicitly using scripting, as in:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myFont = myInDesign.Fonts.Item("Arial Black")
myInDesign.FindPreferences.AppliedFont = myFont
If TypeName(myInDesign.FindPreferences.AppliedFont) <> "String" Then
MsgBox "No font has been set. Please set a font and try again."
Else
MsgBox "Font name is: " & myInDesign.FindPreferences.AppliedFont
End If
It works correctly. The ChangePreferences.AppliedFont does not show the same error.
For now, you might have to display a dialog box for the user to choose the font they want to search for. You can get a list of the available fonts from the InDesign Application object and add their names to a list in a VB form.
Rem Given a form with a List1 control:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
For myCounter = 1 To myInDesign.Fonts.Count
List1.AddItem myInDesign.Fonts.Item(myCounter).Name
Next
Note the font naming convention: <font_family><tab><font_style>. Do not use a For Each...Next loop for this, as it will give you only the first 255 fonts (and you almost certainly have more than that<g>).
Thanks,
Ole
Technical Details
Message-ID:
<1de9d956.2@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de9d956.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,858eccf690fcd37 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-07-09 23:37:48 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Getting FontName from FindPreferences dialog Message-ID: <1de9d956.2@WebX.la2eafNXanI> Date: Wed, 9 Jul 2003 23:32:18 -0700 References: <1de9d956.-1@WebX.la2eafNXanI> Lines: 42 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit