Take text from one Quark doc into another keeping only the f

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 18 Oct 2012, 02:59

We have a catalog that I need to check our prices with our database. Each item is written in a paragraph with the first word being the item number that starts with a letter and end of the paragraph is the price which would be numbers. So I'm needing to take the first word and last word of each paragraph and paste into a new quark document with a tab to seperate then both. This way I can take it into excell and compare it with our database.
ASP53023 LMC Recurve. 4 1/4" closed linerlock. 3 1/4" hollow ground satin finish AUS-8 stainless recurve blade with thumb slot. Textured black FRN handles with removable/reversible black finish stainless pocket clip..............Sale 123.45
ASP53024 LMC Recurve. 4 1/4" closed linerlock. 3 1/4" hollow ground satin finish AUS-8 stainless recurve blade with thumb slot. Textured black FRN handles with removable/reversible black finish stainless pocket clip..............Sale 123.45
ASP53025 LMC Recurve. 4 1/4" closed linerlock. 3 1/4" hollow ground satin finish AUS-8 stainless recurve blade with thumb slot. Textured black FRN handles with removable/reversible black finish stainless pocket clip..............Sale 123.45

Needs to be

ASP53023 $123.45
ASP53024 $123.45
ASP53025 $123.45
Thanks for any help

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

Take text from one Quark doc into another keeping only the f

Post by Emma » 18 Oct 2012, 03:14

This will give you the text you want, then you need to paste it into another document - or directly into Excel?
tell document 1 of application "QuarkXPress"
set first_last_text to ""
tell story 1
repeat with i from 1 to count of paragraphs
if (count of words of paragraph i) > 0 then

tell paragraph i
set first_last_text to (first_last_text & return & first word & tab & last word)
end tell
end if
end repeat
end tell
end tell


-------------------------
[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

Take text from one Quark doc into another keeping only the f

Post by Emma » 18 Oct 2012, 04:00

Just a thought - if you buy XData and XCatalog from Emsoftware, you can build your catalogue with embedded links, and update automatically from your Excel price file. Worth it if you do a lot of this sort of thing!

mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 18 Oct 2012, 06:31

Thank you, but our document could have over 100 pages with pictures, brand titles and group descriptions. Is there a way to strip the data in each paragraph that start with a letter and ends with a number, but keep the first word (item number) and last word (price). Also delete all the other stuff that doesn't start with a letter and ends with a number, like the picture boxes and brands. And still have it with a tab to seperate the item number and price. Or maybe I'm trying to make it to hard, I don't know.

mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 18 Oct 2012, 06:33

I've tried to get the boss to look into that, but with no luck. The software sound great to me.

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

Take text from one Quark doc into another keeping only the f

Post by Emma » 18 Oct 2012, 06:37

Oh, real life! I think I was starting from 'in an ideal world'!
I'm sure it's still do-able. You'd have to add a loop

repeat with j from 1 to count of stories
tell story j...
end tell
end repeat
That would avoid picture boxes at least. Then you'd have to somehow exclude text that wasn't relevant, such as descriptions, folios, page headings. I think you're going to have to develop a solution for your particular job. The 'core' of my script will still do the job, but the problem is narrowing it down. Bit busy just now, but happy to look for solutions when I can.

mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 18 Oct 2012, 07:53

Thank you for the help : ) Your getting me in the right direction.

Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

Take text from one Quark doc into another keeping only the f

Post by Jean-Marie Schwartz » 18 Oct 2012, 20:49

By any chance, are the needed words or figures styled apart? If so, you could then "simply" check the character style applied and get them. Does it make sense?

mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 19 Oct 2012, 03:06

We started to seperate them in style sheet last year, but there still older description that haven't been converted over : ( Good idea that I haven't thought of. Thanks

mark lane
Posts: 4
Joined: 27 Sep 2004, 14:16

Take text from one Quark doc into another keeping only the f

Post by mark lane » 19 Oct 2012, 08:57

My alter script from above just repeats itself and only gets me one result from the first paragarph. It still thinks its the first word of paragraph 1 instead of the next paragraph.

tell document 1 of application "QuarkXPress"
tell story 1
repeat with i from 1 to count of paragraphs
if (count of words of paragraph i) > 0 then
tell paragraph i
set FirstWord to word 1
set LastWord to word -1
set contents to {return & FirstWord & tab & LastWord}
end tell
end if
end repeat
end tell
end tell

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”