3 Replies Latest reply on Jan 31, 2011 1:32 AM by Ten A

    Need help creating an alternate way to place .jpg via URL


      I've created a 20-page layout where each page contains product  photos arranged in a grid. These photos are posted on our web site and  are updated often. To create the document, I laid out my frames and then  placed the URL for each image. E.g., File -> Place -> Filename = http://corpwebsite/products/productphoto1.jpg.  I repeated this for all of the products. I am using this approach  because I don't have access to the server where the photos are stored  and it saves me from having to get copies of each photo and move them to  my local hard drive. I want to automate this process so I wrote a script that would read each URL from an Excel file and place the URL. The code that doesn the place is:


      Set myInDesign = CreateObject("InDesign.Application.CS4")
      Set myDocument = myInDesign.ActiveDocument
      Rem Specify page 5
      Set myPage = myDocument.Pages.Item(5)
      Rem Specify 1st frame
      Set myTextFrame1 = myPage.Rectangles.Item(1)


      It fails on the last line. The error message says "Cannot find the folder." It works if I replace the last line with a reference to an image stored locally:




      I have no idea why a scripted Place command would work differently then manually selecting File -> Place, typing a URL and clicking OK, but that's the reality. So, what I want to do now is update my script to  display the Place dialog box, paste a URL into the dialog box and click the OK button. Unfortunately, I cannot find any info on how to issue keystrokes from within a VB script.


      Can anyone tell me the syntax I need to have a script:


      Display the Place dialog box (CTRL + D)

      Paste a value into it (CTRL + V)

      Click OK


      Using VB, please. Thank you.

        • 1. Re: Need help creating an alternate way to place .jpg via URL
          SoCalMX Level 1

          There is a typo in my post. The line that reads "The code that doesn the place is:" should say "The code that does the place is:"

          • 2. Re: Need help creating an alternate way to place .jpg via URL
            Kasyan Servetsky Level 5

            You have to download the image first and then place it — you can't place it directly from web. I don't know how to do this in VB so I wrote this part in JS and called it via DoScript.

            Here is an example (tested on CS3):

            Private Sub PlaceImage_Click()
                Set myInDesign = CreateObject("InDesign.Application.CS3")
                Set myDocument = myInDesign.ActiveDocument
                Set myPage = myDocument.Pages.Item(5)
                Set myTextFrame1 = myPage.Rectangles.Item(1)
                myJavaScript = "if( webaccesslib == undefined ) {" & vbCr
                myJavaScript = myJavaScript & "if( Folder.fs == 'Windows' ) {" & vbCr
                myJavaScript = myJavaScript & "var pathToLib = '/C/Program Files/Adobe/Adobe Bridge CS3/webaccesslib.dll';" & vbCr
                myJavaScript = myJavaScript & " libfile = new File( pathToLib );" & vbCr
                myJavaScript = myJavaScript & "var webaccesslib = new ExternalObject('lib:' + pathToLib );" & vbCr
                myJavaScript = myJavaScript & "}" & vbCr
                myJavaScript = myJavaScript & "}" & vbCr
                myJavaScript = myJavaScript & "var http = new HttpConnection('http://kasyan.ho.com.ua/images/comp2docs/comp2docs1.png');" & vbCr
                myJavaScript = myJavaScript & "http.response = new File('/c/mypictures/comp2docs1.png');" & vbCr
                myJavaScript = myJavaScript & "http.execute();" & vbCr
                myJavaScript = myJavaScript & "http.response.close();" & vbCr
                myInDesign.DoScript myJavaScript, idScriptLanguage.idJavascript
                myTextFrame1.Place "C:/mypictures/comp2docs1.png"
            End Sub


            Here is an interesting article on web access from InDesign by Kris Coppieters



            • 3. Re: Need help creating an alternate way to place .jpg via URL
              Ten A Adobe Community Professional

              Try this script.


              var cnnct = new Socket;
              if (cnnct.open("chuwa.iobb.net:80", "binary")) {
                  cnnct.write("GET /tech/images/sample1-thumb-240x125.jpg HTTP/1.0\n"
                      + "Host: chuwa.iobb.net\n"
                      + "User-Agent: Mozilla/5.0 (Windows NT 5.1; ja)\n"
                      + "Connection: close\n\n");
                  var rply = cnnct.read(999999);

              var myfile = new File ("/test.jpg");
              if (myfile.open('w')){
                  myfile.encoding = "BINARY";



              It is different way to get image from wab server in Javascript. You can use DoScript method in VB script.