2 Replies Latest reply on Oct 9, 2017 8:00 AM by clutch-cargo

    Pass vbscript variables to javascript string

    clutch-cargo Level 1

      Thx to this forum I can now save AI docs as a TIFF using JavaScript.  With full paths I can run my script with no issues.  Now I need to replace full paths with variables.  So far no luck from what I have tried.  How does one insert variables into a JS being executed inside a vbscript?  Below is my latest attempt.

       

      Also, according to the Illustrator reference guide one must run the JS code as a string when inside vbscript.  No problem but that makes for one very-very long, single line JS.  For "bonus points" , how does break that down the JS into a multi-line string?  My various attempts have failed.  Issue may have to do it while running inside a vbscript?

       

      Set App = CreateObject("Illustrator.Application")

      Set FSO = CreateObject("Scripting.FileSystemObject")

       

      Dim SourceFolder, DestFolder, NewState, NewSection

      Call GetNewInputs()

      Sub GetNewInputs()

            

              NewState = UCase(InputBox("Current STATE or REGION to be processed.", _

              "STATE or REGION", "SOCAL"))

       

              NewSection = ("Section_" & InputBox("INPUT SECTION NUMBER: Section_YY", _

              "Input Section", "32"))

             

              Set SourceFolder = FSO.GetFolder("S:\" & NewState & "\" & NewSection & "\Road DXFs")

              DestFolder = "S:\" & NewState & "\" & NewSection & "\Light TIFFs\"

             

      End Sub

       

      ' now for the JS

      App.DoJavaScript("function test(){var doc = app.activeDocument;var destFile = new File(""/s/" + <%=NewState%> + "/" + <%=NewSection%> + "/Light TIFFs/SOCAL_CN68_resx.tif"");var type = ExportType.TIFF;var opts = new ExportOptionsTIFF();opts.imageColorSpace=ImageColorSpace.GrayScale;opts.resolution=72;opt s.antiAliasing=AntiAliasingMethod.ARTOPTIMIZED;opts.IZWCompression=false;opts.saveMultiple Artboards=true;opts.artboardRange=""1"";doc.exportFile(destFile, type, opts);}test();")

       

      MyDoc.Close(2)