🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
2 messages
2 total messages Started by adMjb Thu, 30 Apr 2009 14:04
paragraph styles in javascript
#215
Author: adMjb
Date: Thu, 30 Apr 2009 14:04
88 lines
5003 bytes
Hi, I want to use this script or something similar:

This is to change one set of styles to another from an imported word
doc in indesign, I have done this which works, but if a style is not
there it errors,
also I am not sure if this its a bad way of doing it? as in using
loads of memory?

Again Any help would be great as I am so new to this its crazy!


// Numbered Paras styles
#target indesign;
app.findTextPreferences = app.changeTextPreferences = null;
app.findChangeTextOptions.includeFootnotes = true;
app.findChangeTextOptions.includeHiddenLayers = true;
app.findChangeTextOptions.includeMasterPages = true;
app.findTextPreferences.appliedParagraphStyle = "MainText Numbered";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Basic";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 1";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 1";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 2";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 2";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 3";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 3";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 4";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 4";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 5";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 5";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 6";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 6";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 7";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 7";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 8";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 8";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 9";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 9";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 10";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 10";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 11";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 11";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 12";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 12";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 13";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 13";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 14";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 14";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 15";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 15";
app.documents[0].changeText();
app.findTextPreferences.appliedParagraphStyle = "Number 16";
app.changeTextPreferences.appliedParagraphStyle = "56 - Numbered Para
Style 16";
app.documents[0].changeText();
/*Clear the find/change preferences after the search.*/
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing
Re: paragraph styles in javascript
#216
Author: adMjb
Date: Fri, 01 May 2009 13:28
36 lines
2415 bytes
I am looking for this but in javascript so I can run it on a PC, I
know nothing of java and would love any help.  Many thanks


on run {input, parameters}

	set DeleteList to {"Heading 1 NoNumber", "Heading 1", "Heading 2",
"Heading 3", "Heading 4"}
	set ReplaceList to {"00 - Chapter Title", "00 - Chapter Title
Numbered", "01 - A Heads", "02 - B Heads", "02 - C Heads"}
		tell application "Adobe InDesign CS4"
		activate
		tell document 1
			set MyStories to every story
			repeat with StoryCount from 1 to (count of MyStories)
				tell (item StoryCount of MyStories)
					repeat with CurrentParagraph from 1 to count of paragraphs
						set ParStyle to name of applied paragraph style of paragraph
CurrentParagraph
						if DeleteList contains ParStyle then
							repeat with x from 1 to count of DeleteList
								if item x of DeleteList is ParStyle then
									set applied paragraph style of paragraph CurrentParagraph to
item x of ReplaceList
								end if
							end repeat
						end if
					end repeat
				end tell
			end repeat

		end tell
	end tell

	return input
end run
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads