oliver82
Gast
Hallo,
ich möchte ein Dokument in Quark durch ein Apple Script automatisch bearbeiten lassen.
Und zwar soll das Script in eine Textfahne gehen welche Tab getrennte Texte enthält, nun
soll das Script Textelemente in dieser Textfahne mit einem bestimmten Style versehen. Und zwar
immer den Text der am Ende einer Zeile steht und vor dem ein Tab ist.
Ich habe da nun auch schon was zusammen gebastelt aber das läuft irgendwie total lahm, da bin
ich per Hand fast schneller
Kann einer mal über das Script bitter drüber schauen und mir einen Hinweis geben was ich evtl.
falsch gemacht habe bzw. was ich besser machen könnte.
Danke und Gruß
Oli
ich möchte ein Dokument in Quark durch ein Apple Script automatisch bearbeiten lassen.
Und zwar soll das Script in eine Textfahne gehen welche Tab getrennte Texte enthält, nun
soll das Script Textelemente in dieser Textfahne mit einem bestimmten Style versehen. Und zwar
immer den Text der am Ende einer Zeile steht und vor dem ein Tab ist.
Ich habe da nun auch schon was zusammen gebastelt aber das läuft irgendwie total lahm, da bin
ich per Hand fast schneller

Kann einer mal über das Script bitter drüber schauen und mir einen Hinweis geben was ich evtl.
falsch gemacht habe bzw. was ich besser machen könnte.
Danke und Gruß
Oli
Code:
tell application "QuarkXPress Passport"
activate
try
-- The following conditionals determine if the proper environment exists
if (exists document 1) is false then error "No document is open."
-- This section will ensure that a single box is selected
set boxCnt to count of (every text box of document 1 whose selected is true)
if boxCnt is not 1 then error "A single box must be selected."
set textBox to current box
set artikelnummerLaenge to 13
tell document 1
set artikelNrTextStylesheet to object reference of character spec "artNr"
-- This line will display an error if the current page is a master page
if masterdoc is true then error "This script doesn't work on master pages."
set myRows to (every paragraph) of story 1 of textBox
set myParagraphNumber to 1
repeat with myRow in myRows
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set myColums to every text item of myRow
set AppleScript's text item delimiters to oldDelimiters
set myWordCount to (count every word of (paragraph myParagraphNumber) of story 1 of textBox)
set myWordCount to myWordCount - (count every word of the last item of myColums)
set myWordCount to myWordCount + 1
if (count of every word of (paragraph myParagraphNumber) of story 1 of textBox) > 2 then
repeat with counter from myWordCount to (count of every word of (paragraph myParagraphNumber) of story 1 of textBox)
if ((count of every character of word counter of (paragraph myParagraphNumber) of story 1 of textBox) = artikelnummerLaenge) then
set character style of (word counter) of (paragraph myParagraphNumber) of story 1 of textBox to artikelNrTextStylesheet
end if
end repeat
end if
set myParagraphNumber to 1 + myParagraphNumber
end repeat
end tell
on error errmsg number errnum
if errnum is not -128 then
beep
display dialog "An Error: " & errmsg & " [" & errnum & "]" buttons {"OK"} default button 1 with icon stop
end if
-- For compatibility with non-US English operating systems
return
end try
-- The following beep will provide feedback of script completion
beep 2
end tell