Skip to main content
September 10, 2015
Answered

Set number of pages in custom XML - InDesign Applescript

  • September 10, 2015
  • 1 reply
  • 573 views

Hi,

Please see my applescript below.

I am trying to write the number of pages within an InDesign document into my custom XMP field.

property pageno : ""

property xmpDomain : "http://myxmp.com/xmp/1.0/"

(*================================

                            Get XMP                          

================================*)

on getXMP(thepath)

  global xmpDomain

  tell application "Adobe InDesign CC 2014"

  tell metadata preferences of active document

  set thevalue to get property namespace xmpDomain path thepath

  end tell

  end tell

end getXMP

(*================================

                            Set XMP                          

================================*)

on setxmp(thepath, thevalue)

  global xmpDomain

  tell application "Adobe InDesign CC 2014"

  tell metadata preferences of active document

  set property namespace xmpDomain path thepath value thevalue

  end tell

  end tell

end setxmp

tell application "Adobe InDesign CC 2014"

  get number of pages of active document

  set pageno to the result

end tell

set pagenumber to my getXMP("pagenumber")

set mypagenumber to pageno

if mypagenumber = pageno then

  my setxmp("pagenumber", pageno)

end if


but i get the following error message, what am i doing wrong?

error "Adobe InDesign CC 2014 got an error: Invalid value for parameter 'value' of method 'set property'. Expected string, but received 1." number 30477




This topic has been closed for replies.
Correct answer Laubender

You need a string, but you provided a number.

Convert the number to string.

In ExtendScript that would be:

pageno = String(pageno);

or:

pageno = pageno.toString();

or:

pageno = pageno + "";

For AppleScript I cannot tell…

But I think, you can figure this out.

Uwe

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
September 10, 2015

You need a string, but you provided a number.

Convert the number to string.

In ExtendScript that would be:

pageno = String(pageno);

or:

pageno = pageno.toString();

or:

pageno = pageno + "";

For AppleScript I cannot tell…

But I think, you can figure this out.

Uwe

September 10, 2015

cool, thanks

i typed in

my setxmp("pagenumber", pageno as string)


worked fine