11 Replies Latest reply on Nov 8, 2012 4:32 AM by qmuli2012

    documentPreferences from an imported XML

    qmuli2012

      Hi,

       

      I am trying to set my documentPreferences from an imported XML as below and I get  - "No data available of the requested type" for mytrimh, could you let me know what I am doing wrong please.

       

      //<snippet>

      function mySnippet(){

          //<fragment>

          //Opens an existing document. You'll have to fill in your own file path

          var myDocument = app.open(File("C:/OpenDocument.indd"));

       

          myDocument.xmlElements.item(0).importXML(File("C:/adlib.xml"));

          var myXMLViewPreferences = myDocument.xmlViewPreferences;

          myXMLViewPreferences.showAttributes = true;

               myXMLViewPreferences.showStructure = true;

               myXMLViewPreferences.showTaggedFrames = true;

               myXMLViewPreferences.showTagMarkers = true;

               myXMLViewPreferences.showTextSnippets = true;

       

       

      }

        

          //<prefs>

      function myPrefs(){

          var myDoc = app.activeDocument

          var mytrimh = myDoc.xmlElements.item(0).xmlElements.item(0).xmlElements.item(-9);

          var mytrimw = myDoc.xmlElements.item(0).xmlElements.item(0).xmlElements.item(10);

          myDoc.documentPreferences.pageWidth = "mytrimh";

          myDoc.documentPreferences.pageWidth = "mytrimw";