Copy link to clipboard
Copied
Hello All,
I'm pretty new in Applescripting but i've written a script to design a page in InDesign CS5 but now i'm trying to set the pagenumber in the same script.
I tried the following but didn't work out:
set mypagenumber to text returned of (display dialog ¬
"set pagenumber" with title "Paginanummer instellen" with icon 1 ¬
default answer "1" buttons {"instellen"} default button 1)
tell application "Adobe InDesign CS5"
set start page number of active document to mypagenumber
end tell
i'll hope somebody can tell me what i'm doing wrong.
Thanks in advance,
Michael
-- The start page number expects an integer, not a text string. Simply coerce to an integer like so:
set mypagenumber to text returned of (display dialog "set pagenumber" with title "set the pagenumber" with icon 1 default answer "1" buttons {"set"} default button 1)
tell application "Adobe InDesign CS6"
tell document 1
tell document preferences
set start page number to (mypagenumber as integer)
end tell
end tell
end tell
Copy link to clipboard
Copied
-- Often, instead of setting a property directly, you must set it within a "tell [...] preferences" block, for example:
tell application "Adobe InDesign CS6"
tell document 1
tell document preferences
set start page number to 14
end tell
end tell
end tell
-- There are several different suites of preferences, so check the Applescript dictionary to see if a property is within a preferences suite.
Copy link to clipboard
Copied
I'm afraid to tell you it did'n solve the problem... but i think the error is in the first line of the script:
set mypagenumber to text returned of (display dialog "set pagenumber" with title "set the pagenumber" with icon 1 default answer "1" buttons {"set"} default button 1)
When i change 'mypagenumber' into e.g. 12 the script works... (set start page number to mypagenumber)
Copy link to clipboard
Copied
-- The start page number expects an integer, not a text string. Simply coerce to an integer like so:
set mypagenumber to text returned of (display dialog "set pagenumber" with title "set the pagenumber" with icon 1 default answer "1" buttons {"set"} default button 1)
tell application "Adobe InDesign CS6"
tell document 1
tell document preferences
set start page number to (mypagenumber as integer)
end tell
end tell
end tell
Copy link to clipboard
Copied
Thank you AS Scripter,
With your awnser i solved the problem. The script looks like below and works very well
tell application "Adobe InDesign CS5"
set DocumentName to name of front document as string
set documentorspecial to characters 4 thru 4 of DocumentName as string
if documentorspecial is "_" then
set x to false
end if
if x is false then
display dialog "Gestopt, dit is een complete special" giving up after 2 --documentofspecial
error number -128
end if
end tell
display dialog "filename is " & DocumentName & " vierde karakter is " & documentorspecial
display dialog "set pagenumber" with title "set the pagenumber" with icon 1 default answer 1 buttons {"set"} default button 1
set mypagenumber to text returned of the result as number
tell application "Adobe InDesign CS5"
set myDocument to document 1
activate
tell document preferences of myDocument
set start page number to mypagenumber
set facing pages to true
set allow page shuffle to true
end tell -- document preference
end tell --application InDesign
--if is_odd(the mypagenumber) is false then display dialog "linker pagina"
--if is_odd(the mypagenumber) is true then display dialog "rechter pagina"
on is_odd(this_number)
if this_number mod 2 is not 0 then
return true
else
return false
end if
end is_odd
Thanks again for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now