2 Replies Latest reply on Sep 29, 2009 8:59 AM by Nlwest

    [VB] Print to file using print preset

    Nlwest User Group Manager

      I'm new to InDesign and ID scripting, and am mainly trying to work with sample scripts to figure this out. I've searched the forum and found a couple of Javascript references to how to assign print presets and feed the path and filename for a postscript file into ID. The script below will create a postscript file, but is not using the preset when it does so. Until I added the print reference to idPostscriptFile, it was just using whatever printer was last printed to in ID. So I have a print file now, but it's still not using the printer preset I want it to use. I'd appreciate it if anyone could point me in the right direction. Thanks!

       

      main
      Function main()
      Set myInDesign = CreateObject("InDesign.Application")
      mySetup myInDesign
      mySnippet myInDesign
      myTeardown myInDesign
      End Function
      Function mySetup(myInDesign)
      End Function
      Function mySnippet(myInDesign)

      Set myDocument = myInDesign.Open("C:\IDFILE.indd",False)
      Set myDocument = myInDesign.Documents.Item(1)
      Set myTextFrame = myDocument.TextFrames.Item("FrameName")
      myTextFrame.ParentStory.Export idExportFormat.idTaggedText, "C:\FILENAME"
      myDocument.PrintPreferences.printer = idPostscriptFile
      myDocument.PrintPreferences.PageRange = "1-2"
      Set myPrinterPreset = myInDesign.PrinterPresets.Item("PRESETNAME")
      MyPrinterPreset.PrintFile = "c:\POSTSCRIPTFILE.PS"
      MyDocument.PrintOut False
      End Function
      Function myTeardown(myInDesign)
      End Function

        • 1. Re: [VB] Print to file using print preset
          Kasyan Servetsky Level 5

          Try this — I can't check this code right now, but hope it works:

           

          Function mySnippet(myInDesign)
              Set myDocument = myInDesign.Documents.Item(1)
              Set myTextFrame = myDocument.TextFrames.Item("FrameName")
              myTextFrame.ParentStory.Export idExportFormat.idTaggedText, "C:\FILENAME"
              myDocument.PrintPreferences.Printer = idPostscriptFile
              Set myPrintPrefs = myDocument.PrintPreferences
              myPrintPrefs.PageRange = "1-2"
              myPrintPrefs.ActivePrinterPreset = myInDesign.PrinterPresets.Item("PRESETNAME")
              myPrintPrefs.PrintFile = "c:\POSTSCRIPTFILE.PS"
              myDocument.PrintOut False
          End Function

           

          Set myDocument = myInDesign.Open("C:\IDFILE.indd",False)
          Set myDocument = myInDesign.Documents.Item(1)

          You don't need to set this variable twice — use one of them.

           

          Kasyan

          • 2. Re: [VB] Print to file using print preset
            Nlwest User Group Manager

            That worked beautifully! Thanks so much! -- Nancy