[news]Hier nog even op doorbomen (en zelf geknutseld) heb ik bij deze een AppleScript in elkaar gebokst dat van een openstaand document een paginanummer opvraagt en daarna toont hoeveel kaders, tekens, woorden en paragrafen deze pagina bevat.
Zou zowel moeten werken voor InDesign CS en InDesign CS2.
Hoe kan je dit script nu gebruiken in InDesign;
- Kopieer de tekst hieronder (in Code kadertje) en plak deze in een nieuw document van Script Editor (te vinden onder Programma's -> AppleScript map)
- Als je het script wilt gebruiken voor InDesign CS moet je de regel tell application "Adobe InDesign CS2" aanpassen naar de applicatie naam van CS1 ... normaal is dat InDesign CS dus tell application "InDesign CS"
- Druk op Enter waarna AppleScript de syntax van script zal controleren. Wanneer dit gebeurt zal je InDesign opgestart worden. Dit is noodzakelijk anders kan AppleScript de syntax niet controleren, je spreekt in het script immers InDesign aan, vandaar.
- Bewaar het document als een Script
- Plaats het in de Script map van InDesign. Dit is onder de InDesign applicatiemap -> Presets -> Scripts
- Nu zou dit script moeten toegankelijk zijn in InDesign zelf, als je script palet openzet. Bij InDesign CS onder Window -> Scripting -> Scripts , en bij InDesign CS2 onder Window -> Automation -> Scripts (sorry Engelse versie van CS2 hier).
- Gewoon dubbel klikken op het script om het uit te voeren, en ziedaar de wonderen van het optellen.
Als je dat wilt kan je script nog uitbreiden en allerhande zaken gaan opvragen van een bepaalde pagina, zoals gebruikte lettertypes, beelden, stijlen ... noem maar op.
Voor wie hier iets mee kan aanvangen.
En nu, zonder verder dralen de code;
set v_CR to ASCII character 13
set v_CountFrames to 0 as integer
set v_CountChars to 0 as integer
set v_CountWords to 0 as integer
set v_CountParagraphs to 0 as integer
tell application "Adobe InDesign CS2"
if (count of documents) = 0 then
display dialog "Geen document geopend." & v_CR & v_CR & "Open eerst een document en probeer dan opnieuxw om een pakket aan te maken." buttons {"OK"} with icon caution
return
end if
tell active document
set v_PageCount to count of pages
set v_Result to display dialog "Geef de pagina op waarvoor moet geteld worden (max. waarde is " & (v_PageCount as string) & "): " default answer "1" with title "Pagina info" buttons {"OK", "Annuleer"} default button {"OK"}
if button returned of v_Result is equal to "Annuleer" then
--user cancelled, so bail out
return
end if
set v_Page to text returned of v_Result as integer
if v_Page > v_PageCount then
display dialog "Opgegeven pagina bestaat niet." buttons {"OK"} with icon caution
return
end if
--start counting by getting all text frames
--
tell page v_Page
set v_TextFrames to text frames
set v_CountFrames to count of v_TextFrames
repeat with v_Frame in v_TextFrames
set v_FrameProps to properties of v_Frame
set v_CountChars to v_CountChars + (length of contents of v_FrameProps) as integer
set v_CountWords to v_CountWords + (count words of contents of v_FrameProps) as integer
set v_CountParagraphs to v_CountParagraphs + (count paragraphs of contents of v_FrameProps) as integer
end repeat
end tell
end tell
--make dialog to show results
--
set v_Dialog to make dialog with properties {name:"Pagina informatie", can cancel:false}
tell v_Dialog
tell (make dialog column)
tell (make dialog row)
make static text with properties {static label:"Kaders:", min width:80}
make static text with properties {static label:(v_CountFrames as string)}
end tell
tell (make dialog row)
make static text with properties {static label:"Karakters:", min width:80}
make static text with properties {static label:(v_CountChars as string)}
end tell
tell (make dialog row)
make static text with properties {static label:"Woorden:", min width:80}
make static text with properties {static label:(v_CountWords as string)}
end tell
tell (make dialog row)
make static text with properties {static label:"Paragrafen:", min width:80}
make static text with properties {static label:(v_CountParagraphs as string)}
end tell
end tell
end tell
set v_Result to show v_Dialog
end tell
Have fun.
TLM
[/news]