🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18298

Constants--numeric vs. named (VB)

#18298
From: pjredman
Date: Fri, 04 Apr 2003 22:40
93 lines
3988 bytes
I have a script that creates a report of each paragraph and character style in the active document. Some of the style attributes (like "Case") are reported back as numeric constants, which are not intuitive to interpret in a report. Is there a way to get these as text constants, like idNormalCase instead of 1851876449?

Here's an abridged version of the script so you can see what I'm up to:

Private Sub Command1_Click()
' This script produces a listing of paragraph and character styles and their associated attributes for a document.
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.ActiveDocument

Text1.Text = "Working..."

' Create a text file to store the style list
Dim fso, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile("c:\temp\listfile.txt", True)

' Inventory the paragraph styles and their attributes. This is a subset of all
' possible attributes. Store the style name and attributes in the .txt file
txtfile.WriteLine ("Paragraph Styles for" & " " & myDocument.Name & vbCr)
psCount = myDocument.ParaStyles.Count
For i = 2 To psCount
Set myStyle = myDocument.ParaStyles.Item(i)

txtfile.WriteLine ("Style Name" & vbTab & vbTab & myStyle.Name)

txtfile.WriteLine ("Based On" & vbTab & vbTab & myStyle.BasedOn)

txtfile.WriteLine ("Next Style" & vbTab & vbTab & myStyle.NextStyle)

txtfile.WriteLine ("Font" & vbTab & vbTab & myStyle.AppliedFont)

txtfile.WriteLine ("Point Size" & vbTab & vbTab & myStyle.PointSize)

txtfile.WriteLine ("Leading" & vbTab & vbTab & myStyle.Leading)

txtfile.WriteLine ("Case" & vbTab & vbTab & myStyle.Case)

txtfile.WriteLine ("Position" & vbTab & vbTab & myStyle.Position)

txtfile.WriteLine (vbCr)

Next i

' Inventory the character styles and their attributes. This is a subset of all
' possible attributes. Store the style name and attributes in the .txt file
txtfile.WriteLine ("Character Styles for" & " " & myDocument.Name & vbCr)
csCount = myDocument.CharStyles.Count
For i = 2 To csCount
Set myStyle = myDocument.CharStyles.Item(i)

txtfile.WriteLine ("Style Name" & vbTab & vbTab & myStyle.Name)

Next i

txtfile.Close

' Set up the InDesign report file and text frame
Set reportDocument = myInDesign.Documents.Add
Set myPage = reportDocument.Pages.Item(1)
myX = myPage.MarginPreferences.MarginLeft + 1
myY = myPage.MarginPreferences.MarginTop + 1

' Place the .txt file in the text frame
myPage.Place "c:\temp\listfile.txt", Array(myX, myY), , False, True, True, True

' Clean up .txt file
Set fil1 = fso.GetFile("c:\temp\listfile.txt")
fil1.Delete

' Format the text
Set myTextFrame = reportDocument.TextFrames.Item(1)
Set myStyle = reportDocument.ParaStyles.Add
myStyle.Name = "Body"
' myStyle.FontStyle = "Times Roman"
Set myTabStop1 = myStyle.TabStops.Add
myTabStop1.Alignment = idLeftTab
myTabStop1.Position = "14p"
Set myTabStop2 = myStyle.TabStops.Add
myTabStop2.Alignment = idLeftTab
myTabStop2.Position = "22p"

Set myStory = reportDocument.Stories.Item(1)
For i = 1 To myStory.Paragraphs.Count
Set myPara = myStory.Paragraphs.Item(i)
myPara.ApplyStyle (myStyle)
Next i
Text1.Text = "Done!"
Beep
End Sub

Thanks,
Phil Redman
Technical Details
Message-ID: <1de89b13.-1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,86d4ab3a2d3642a2,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-04-04 15:07:50 PST
From: pjredman <pjredman@usgs.gov>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Constants--numeric vs. named (VB)
Message-ID: <1de89b13.-1@WebX.la2eafNXanI>
Date: Fri, 4 Apr 2003 14:40:28 -0800
Lines: 105
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit