12 Replies Latest reply on Jul 23, 2008 8:22 AM by (Olav_Kvern)

    Scripts running slow (VBS)

      I have been converting scripts that we have used in CS and CS, to CS3. The scripts appear to work just the same and I have them running now but they appear to take quite a long time to finish compared to when they ran in CS and CS2.

      Is this normal in CS3?
      Did CS3 Type Library change so much that it these older scripts run slower?

      I was just curious, thanks!
        • 1. Re: Scripts running slow (VBS)
          Level 1
          Hi bstimpson,

          They should run faster--there were many performance improvements in scripting between CS and CS3. If they're running slower, it's probably due to something else about your installation. Being short on hard drive space and/or memory resident antivirus software that monitors disk write operations are the two that come to mind first. InDesign *always * writes to disk--for every change to the document. Anything that gets in the way of that process will slow things down.

          If you have antivirus software running--is it possible that it's set to allow an exception for CS/CS2 and not for CS3?

          Thanks,

          Ole
          • 2. Re: Scripts running slow (VBS)
            Dirk Becker  Level 4
            As I understand it (never experienced that myself because I prefer JS) there is a speed advantage of VBA running from within InDesign, over VB compiled code going thru COM. I would not even know whether VBS counts to the former or latter :)

            Dirk
            • 3. Re: Scripts running slow (VBS)
              Level 1
              I'm far from being an expert in either InDesign or VBS, but I tried it on several different machines and I'm getting the same result as far as speed. It's just so strange that CS/CS2 work quickly and CS3 is going very very slow. Scripts that used to take 5 seconds are taking near a minute. I'll definitely check into the Anti-virus software.

              I appreciate your comments and will continue to try and resolve this issue. Thanks!
              • 4. Re: Scripts running slow (VBS)
                Level 1
                Hi Dirk,

                VBScripts run from the Scripts panel will run the fastest--VBA and compiled Visual Basic programs will be slower.

                Hi bstimpson,

                What is your script trying to do? We might find some clues there.

                Thanks,

                Ole
                • 5. Re: Scripts running slow (VBS)
                  Level 1
                  I am running all the scripts from the Script Panel in .vbs format.

                  There are a few scripts but the one that takes the most time is a Converter type script.

                  The script selects a textframe (new or existing) and forms it into a table. It formats the text to a specific font type, size, etc. It them opens a dialog box that allows us to decide how many header rows there are and pick specific fill colors.

                  So there is a quite a bit going on but it's lightning fast with CS and CS2. Hopefully this makes sense, thanks for all the help!
                  • 6. Re: Scripts running slow (VBS)
                    Level 1
                    Hi bstimpson,

                    How does your script do the text to table conversion? In CS3, you'll need to use the ConvertToTable method--it's a little different from the way we did it in earlier versions. It's possible that the speed problem has something to do with this--I'm guessing it's something else, but let's keep talking.

                    Thanks,

                    Ole
                    • 7. Re: Scripts running slow (VBS)
                      Level 1
                      We did make that change for CS3. After going through the myStory and setting the Font, PointSize, FontStyle, etc. It shows this -

                      Set myTable = myText.ConvertToTable

                      After that it brings up the dialog box.
                      • 8. Re: Scripts running slow (VBS)
                        Level 1
                        OK I've checking logs of Webroot and tested on a few different machines and they are still running very slow.

                        All the machines I tested with run the exact same scripts very fast in CS and CS2 but when I make minor changes to the scripts to work in CS3, they work but again it's very very slow.

                        Any other ideas or settings that may help speed them up?

                        Thanks again for any suggestions!
                        • 9. Re: Scripts running slow (VBS)
                          Level 1
                          I have found the reason for my slow scripts in InDesign CS3. I noticed that CS/CS2 do not show the actual steps of formatting that CS3 (by default) does. This cuts the time in half for it to run through scripts that deal with larger tables.

                          It appears that ReDraw is set to True by default for CS3.

                          Looking through the CS3 Type Library there appears to be a flaw because it states "ScriptPreference" as an option when you actually have to use "ScriptPreferences" plural to make it work correctly.

                          I used the following code in VBS to stop the ReDraw.

                          myInDesign.ScriptPreferences.EnableReDraw = false

                          Hopefully this helps anyone else running into a similar problem. Thanks!
                          • 10. Re: Scripts running slow (VBS)
                            Level 1
                            Hi bstimpson,

                            Glad you solved it!

                            "ScriptPreference" is the *type*--if you look at the Application object, you'll see that the element (or property) is "ScriptPreferences". It's this way for all preference objects.

                            Thanks,

                            Ole
                            • 11. Re: Scripts running slow (VBS)
                              Level 1
                              OK makes sense I just didn't notice that. Thanks for clarifying.
                              • 12. Re: Scripts running slow (VBS)
                                Level 1
                                Hi bstimpson,

                                It is confusing--it's just something we have to do for various language compatibility reasons (remember, we're trying to support--at least--three different scripting languages with a single model). It gets tricky at times. But it's better than supporting only a single language!

                                Thanks,

                                Ole