Converting words in caps to words styled as caps (Quark)

Hi all,

we used to use a Xtension in QXPress that did the following:
Find text TYPED in capitals (not styled as capitals) and replace this in lowercase and then make in smallcaps. (Search for ‘Space-typed in capitals 2 or more characters - space’ and then convert)

However, this worked only in QXPress versions up-to 4.1
We are looking for a way to do this in QXPress version 6 OR in the Word files that are imported.
We contacted the Vision Edge, Badia, Alap and Markzware but they showed no interest in this kind of function.

Can it be done in Apple script?

To be more precise:
We need to covert acronyms like USA, EU, UWV, NS etc. etc.
Clients type this words in Word in capitals NOT style them as capitals.
In QXPress (and Word) we can search only for styled text.
So what we need to do is:
Search for ‘SPACE-TYPED IN CAPITALS 2 OR MORE CHARACTERS-SPACE’
Ex: SPACE-USA-SPACE.
We do NOT want/need to find a word like Opec, only ‘whole’ words that are totally typed in capital!

This is the main part.
Any addition like converting it to lowercase and even apply ‘smallCaps’ as style would be very handy as well, but finding the words is the main job.

Doing it right in QXPress version 6 would be great, but doing it in the Word file is also a possibility

(As every file has many, many acronyms and we do not know which ones are in a file, we can not search for known expressions)

Anyone?
I can not thank enough anyone that can help me.
it would be SO appreciated!!!

Thanks in advance.

Wilma

Hello Wilma,

Have you tried doing a search on this site for “Quark”? I just did, and came up with 214 threads. I hope this helps.

Sincerely,

Variable as the shade

Wilma,

What you are wanting to do is possible with AppleScript but is pretty complicated and would not be very fast. The only way I know of to do this would be to check every letter of every word, then check the ASCII number (the numerical value) of each letter. It can be done using AppleScript but if your document is longer than say 10 pages, it will be pretty slow.

I do not know this as a certainty however. Someone else around this BBS may have a better answer.

Scott Lewis
MacScripter Staff | unScripted

You can find a string of uppercase letters surrounded by spaces by using the free Satimage osax, which has regular expression searching.

You can get the osax, which has very good documentation, here:
Satimage osax

The regular expression for finding your string would be:
b[A-Z][A-Z]+b

b is a word boundary. [A-Z] is any one uppercase character. [A-Z]+ is one or more uppercase characters.

Assign your text to a variable and pass that variable to a handler that changes the upper case to a lower case.

You can find a string of uppercase letters surrounded by spaces by using the free >Satimage osax, which has regular expression searching.

You can get the osax, which has very good documentation, here:
Satimage osax

Thanks!
I’ll be looking into this!

You certainly can search for all cap words in Word! Check out the article in the current Macworld magazine for some details. In essence:

Open the Find/Replace window.

Click the disclosure triangle to reveal additional search options.

Click the “Special” popup. Select the range of characters. It will shows up as “[-]”. Type “A” before the hyphen, “Z” after. That will find any capital letter. You want to find a sequence of two or more (e.g., not “I” or “A”), so add “Number of occurrences” after the string, and put a “2” in front of the comma, leaving the upper limit unspecified. Finally, if you want to find only whole words, bracket the expressions with “Begin word” and “End word”, so you wind up with: <[A-Z]{2,}>

If you do a “find all”, Word will highlight all uppercase words. You can then use Word’s change case command to change it to lowercase.

If you Record the above sequence and save it as a macro, you’ll have a Word VBA script that does the job.

Hello Allen,

You certainly can search for all cap words in Word! Check out the article in the current Macworld magazine for some details. In essence:

I got it!
you have to select the option 'Use Wildcards!
But it still finds ALL capitals at the beginning of a sentence also…
How can you narrow it down to only words that have 2 or more capitals?
And: how do I find words that are between brackets like ‘The organisation - (ORG) - that is mentioned’ how do I find (ORG), same with EU-connections?
If this can be done I’m VERY happy!

BTW: wich issue of Macworld is it? And: the US edition?

THANK YOU!

WOW!

To answer my own question:

[A-Z][A-Z]?*

And ‘Use Wildcards’

It does EXACTLY what I need. I can give all expressions an ‘underline’ and then search in QXPress for this underline style and replace it with a character smaalcaps style

Allen, you are wonderfull!
THANK YOU!!

:smiley: [bowing] Thanks.

Lots of hidden treasures in Word. The Macworld issue is March 2004, pp 70-71, US edition. Good article.

I think you can also apply small caps right in Word, can’t you? Or is there a reason you have to do that in Quark?

If anyone is interested, I do have a very fast script that will convert ALL CAPS to lowercase with small caps style applied directly in QXP. As I said, it is very fast. On a test, it runs through a 100-page file with lots of words to convert (6 different acronyms used over 12,000 times) in less than 30 seconds on a PowerBook G4 1.25Ghz. To use the script, there is a small licensing fee. Contact me if you want more information.

Jon

Jon,

I also mailed you, but:
how ‘big’ is the price/fee you are asking?

I am very happy with this. The reason for doing it in Quark is that we use a ‘Expert’ font with real smallcaps, not styled. But your solution works fine (now and then a last character of a word is not selected, can not find any logic i this, but that is easy to spot and change. Maybe the search string can be refinded - any suggestions are welcome by the way :wink: )

OK, I refined it to:

<[A-Z][A-Z]*>

This will higlight UWV in the follwing:

UWV
(UWV)
UWV-connections

It will NOT select the brackets () or the hyphen - etc, only the whole word.
Works like a charm!

I tried to Applescript Word as follows:

tell application “Microsoft Word”
activate
do Visual Basic " With Selection.Find
.Text = “<[A-Z][A-Z]*>”
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With"
set small caps of selection to toggle
do Visual Basic " Selection.Range.Case = wdLowerCase"
end tell

But I keep getting ‘Syntax error’ from visual basic.
Anyone an idea how to make this into a script?

I’m no VB expert, so my recommendation here would be to record the whole operation, performing it using the usual menu items or keystrokes, naming it something unique, and then examine what gets recorded. HOWEVER, I tried doing that. The Find All that gets recorded, if you record it by itself, does not work when I run the recorded macro. Apparently there is a bug in either recording or in the VB execution. Bummer.

This script was the rtesult of a ‘recording’, so there indeed seems to be a problem. Is not that important as I can still do it ‘by hand’ :wink: