Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

automatic page numbering with AS

New Here ,
May 19, 2015 May 19, 2015

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

TOPICS
Scripting
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , May 27, 2015 May 27, 2015


-- 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


Translate
Participant ,
May 20, 2015 May 20, 2015

-- 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2015 May 26, 2015

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 27, 2015 May 27, 2015


-- 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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2015 May 29, 2015
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines