6 Replies Latest reply on Apr 19, 2013 8:20 AM by indesign_adam

    Setting Document Measurement Units

    indesign_adam

      Dear Forum Gods,

       

      I am trying to use a VB script to set what I believe to be the Measurement Units - that is, the units displayed on the horizontal and vertical rulers when opening a document. According to the scripting guide:

       

      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches
      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches

       

      This does not appear to do anything.

       

      Log reports error 30480 -- which I cannot find any information on.

       

      Your help is appreciated!

        • 1. Re: Setting Document Measurement Units
          [Jongware] Most Valuable Participant

          Are you looking at the VB reference? Yur line looks suspiciously like a JavaScript line, and JavaScript does nothave  the same syntax as VB.

           

          A quick Google turned up the CS5 VB Reference; your Measurement example is on p. 28, but with different wording.

          • 2. Re: Setting Document Measurement Units
            indesign_adam Level 1

            Thanks, I changed the syntax but it still doesn't seem to work.

             

            I see an error 424 in the log now. VB error descriptor says 'Object Required.' What am I missing here?

             

             

                      Set myDocument = myInDesign.Documents.Add
                      Set oArgs = WScript.Arguments.Unnamed
                      objTextFile.WriteLine("InDesign after Add Docs")
                 If Err.Number <> 0 then
                   objTextFile.WriteLine("After Obj  Error = " & Err.Number)
                 End If
                 Err.Clear     
                      myDocument.marginPreferences.left = 0
                      myDocument.marginPreferences.right = 0
                      myDocument.marginPreferences.top = 0
                      myDocument.marginPreferences.bottom = 0
                 If Err.Number <> 0 then
                   objTextFile.WriteLine("Set Margins: Error = " & Err.Number)
                 End If
                 Err.Clear
                      myDocument.ViewPreferences.HorizontalMeasurementUnits = idMeasurementUnits.idInches
                      myDocument.ViewPreferences.VerticalMeasurementUnits = idMeasurementUnits.idInches
                 If Err.Number <> 0 then
                   objTextFile.WriteLine("Set Measurement Units: Error = " & Err.Number)
                 End If
                 Err.Clear
                      Set myPage = myDocument.pages(1)
                      myPage.marginPreferences.left = 0
                      myPage.marginPreferences.right = 0
                      myPage.marginPreferences.top = 0
                      myPage.marginPreferences.bottom = 0
            
                      With myDocument.DocumentPreferences
                      .PageHeight = oArgs.Item(1)
                      .PageWidth =  oArgs.Item(2)
                      .PagesPerDocument = 1
                      End With
            
            • 3. Re: Setting Document Measurement Units
              indesign_adam Level 1

              I think I had a similar problem before where the id___.id___ values were not working. To set UserInteractionLevel, I had to find the numeric value of idNeverInteract. Do you know why this is happening? Is there somewhere I can find a conversion for the id's?

              • 5. Re: Setting Document Measurement Units
                [Jongware] Most Valuable Participant

                Um, yes I am -- that is, 'him', not the 'prince' part :-P You are welcome!

                 

                .. Can I talk you into switching over to JavaScript? Mind you, VB has its advantages for certain workflows: mainly because it allows data interchange between ID and Office software. But if you are beginning *anyway*, the 'learning curve' is quite similar, and you are bound to find other uses for JS.

                • 6. Re: Setting Document Measurement Units
                  indesign_adam Level 1

                  Yes, we usually write JS, but in this case I was augmenting an existing resource.

                   

                  Thanks again.