🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16369

[VP] Searching for words that are in CAPS in all pages of a doc.

#16369
From: Guy Verville
Date: Fri, 19 Sep 2003 03:01
48 lines
2558 bytes
I have a lenghty bibliography where the author's last names have been put in uppercase. I want to search all those uppercase names and apply a special character style to all the letters to them except the first (mimicking a Small Caps). The Character Style is called "BiblioCaps".

I can change the first page of the bibliography, but my PageLoop doesn't work. It's certainly a misunderstanding of how to navigate through a doc. Here is my routine. Perhaps there is a better way to do this...

* ************************************* Dim WordsCount, PagesCount, ParagraphsCount, CharactersCounti, j, k, number, letter

Set myindesign = CreateObject("InDesign.Application.2.0")
Set MyPages = myindesign.ActiveDocument.Pages
PagesCount = MyPages.count
For i = 1 to PagesCount
	'Set the Base TextFrame
	Set MyActualTextFrame = MyPages.Item(1).TextFrames.Item(1)
	'Get Paragraphs count in the TextFrame
	Set MyParagraphs=MyActualTextFrame.Paragraphs
	ParagraphsCount=MyParagraphs.count

	'Paragraph Loop
	For l=1 to ParagraphsCount
		'Get WordsCount
		Set MyWords = MyParagraphs.Item(l).TextWords
		WordsCount= MyWords.Count

		'Words Loop
		For j = 1 to WordsCount
			'This is the word
			letter = MyWords.item(j).TextContents
			'Get the Word Lenght	
			CharactersCount=Len(MyWords.Item(j).Textcontents)
			'If word is long enough
			If CharactersCount > 3 Then
				'To avoid testing capitalized letter, begins with the second letter of the world
				number=Asc(Mid(letter,2,1))
				If number > 64 and number <91 or number >191 and number <222 Then
					For k=2 to CharactersCount
						MyWords.Item(j).Characters.Item(k).CharacterStyle="BiblioCaps"
					Next
					CharactersCount=0
				End If
			End If
		Next
	Next
Next
	MsgBox "Finish"
* **************************************

Thanks for your help!

Guy
Technical Details
Message-ID: <2ccd79e1.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!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,75fd2c48ad6aecbf,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-09-18 20:08:02 PST
From: "Guy Verville" <taddeus@spamcop.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!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: [VP] Searching for words that are in CAPS in all pages of a doc.
Message-ID: <2ccd79e1.-1@webx.la2eafNXanI>
Date: Thu, 18 Sep 2003 20:01:40 -0700
Lines: 56
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit