Monday, April 22, 2019

#1 2019-04-11 09:05:44 am

Paeon
Member
From:: Chicago
Registered: 2005-11-01
Posts: 88
Website

Speeding up a Microsoft Word handler

My script is feeding a long string made from a list of articles in InDesign. I am outputting a Microsoft Word document. I want to delineate the "title" paragraphs of the string from the rest. I made this handler:

Applescript:


on textblue()
   with timeout of 60000 seconds
       tell application "Microsoft Word"
           set myPars to every paragraph of active document
           set myTitle to text object of paragraph 1 of active document --first paragraph
           set color index of font object of myTitle to blue --first paragraph is blue
           repeat with aPar in myPars --rest of the paragraphs
               if content of text object of aPar starts with "Story: " then --signifies the first paragraph of an article
                   
                   set myRange to text object of aPar
                   
                   set color index of font object of myRange to blue
               end if
           end repeat
       end tell
   end timeout
end textblue

Problem is this takes a really long time. Is there a way of speeding this up?


Filed under: Word

Offline

 

#2 2019-04-12 12:23:43 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 62

Re: Speeding up a Microsoft Word handler

Your request for help is not clear. What is this document? Is this originally a Word or InDesign document? Is it updated and how often? Why such a huge timeout?

Let's start with this:

Applescript:



tell application "InDesign" to set myPars to every paragraph of active document -- save list of articles

set myTitle to item 1 of myPars -- get main title text

tell application "Microsoft Word"
activate
repeat with aPar in myPars --rest of the paragraphs
if aPar starts with "Story: " then --signifies the first paragraph of an article
---- Next, you build in Word new text, taking the text from the list of articles that already you have and apply color formatting, etc. depending on first word of each article

And yet, what is this document InDesign? If this is PDF and you want change to blue the beginning of each article and keep the rest of the formatting style and lagout, then you need not a Word, but a PDF editor, such as Infix PDF Editor. There is another way too - to create a new PDF with desired formatting, applying poor AppleScript means

Last edited by KniazidisR (2019-04-12 01:13:59 pm)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)