|
WORD
COUNT
--This
script will provide a word count for selected text, the current
story or entire InDesign CS document.
tell
application
"InDesign 2.0.2" --works
with InDesign CS too.
if
(count
of
every
document)
> 0 then
if
(count
of
every
story
of
document
1) > 0 then
set
selected_words
to
0
set
selected_characters
to
0
set
story_words
to
0
set
story_characters
to
0
set
all_words
to
(count
of
every
word
of
every
story
of
document
1)
set
all_words_sum
to
0
repeat
with
n
in
all_words
set
all_words_sum
to
all_words_sum
+ n
end
repeat
set
all_characters
to
(count
of
every
character
of
every
story
of
document
1)
set
all_characters_sum
to
0
repeat
with
n
in
all_characters
set
all_characters_sum
to
all_characters_sum
+ n
end
repeat
try
if
(count
of
words
of
selection)
as
text
≠ "" then
set
selected_words
to
count
of
words
of
selection
set
selected_characters
to
count
of
characters
of
selection
end
if
end
try
if
class
of
selection
is
in
{insertion
point, text}
then
set
story_words
to
count
every
word
of
parent
of
selection
set
story_characters
to
count
of
every
character
of
parent
of
selection
end
if
display
dialog ("
Selection (" & selected_words
& " words/" & selected_characters
& " characters)
Story (" & story_words
& " words/" & story_characters
& " characters)
Document (" & all_words_sum
& " words/" & all_characters_sum
& " characters)") buttons
{"OK"} default
button 1
else
display
dialog "No
text in document."
end
if
else
display
dialog "No
document open."
end
if
end
tell
--Copyright©2004
Flux Consulting
--May not be republished without permission.
--Need a custom automation developed for your business?
--Send inquires to
info@fluxconsulting.com or call 212-414-1662.
--Please report bugs to bugs
info@fluxconsulting.com
|