Linebreak script unreliable

T

Tobias Weber

Hi,
got the following script from somewhere (Google doesn't find it) and
only modified the replace strings. I use this on Japanese text to make
single paragraph breaks into soft line breaks. Unfortunately it only
works *sometimes* but usually does absolutely nothing.

tell application "Microsoft Word"
set docRange to text object of selection

clear formatting of find object of docRange
execute find (find object of docRange) find text "^p^p" replace with
"•" replace replace all without match sounds like

clear formatting of find object of docRange
execute find (find object of docRange) find text "^p" replace with
"^l" replace replace all without match sounds like

clear formatting of find object of docRange
execute find (find object of docRange) find text "•" replace with
"^p" replace replace all without match sounds like
end tell
 
M

Mitrokhin

i microsoft.public.mac.office.word skrev Tobias Weber
torsdag 12. juni 2008 20:01:58 (lokal tid), i en artikel med
ID <[email protected]>
og titlen "Linebreak script unreliable", følgende:


: Hi,
: got the following script from somewhere (Google doesn't find it) and
: only modified the replace strings. I use this on Japanese text to make
: single paragraph breaks into soft line breaks. Unfortunately it only
: works *sometimes* but usually does absolutely nothing.
:

Hi


try replacing the first two lines, ie:

: tell application "Microsoft Word"
: set docRange to text object of selection

with this:

-->
tell application "Microsoft Word"

if selection's selection type ‚ selection ip then
-- if a selection exists
set docRange to (text object of selection)
else
set docRange to (text object of active document) -- redo each time
end if
--->

and see if that helps.
 
T

Tobias Weber

Mitrokhin said:
try replacing the first two lines, ie:

Of course I took care to select all text before running the script.
Unfortunately your change didn't help.
 
M

Mitrokhin

i microsoft.public.mac.office.word skrev Tobias Weber
torsdag 12. juni 2008 21:14:00 (lokal tid), i en artikel med
ID <[email protected]>
og titlen "Re: Linebreak script unreliable", følgende:

: In article <120620081842257907%[email protected]>,
:
: > try replacing the first two lines, ie:
:
: Of course I took care to select all text before running the script.
: Unfortunately your change didn't help.
:


Well it does work for me, with *or* without a selection.

Let's hope someone more knowledable than me and you
comes along then.


: --
: Tobias Weber
:
 
D

Daiya Mitchell

Hi Tobias,

I'm very weak on scripting, but my first guess would be that there could
be a bug with how F&R works on Japanese text. Can you test the script
itself on English/Roman alphabet text and see if it is reliable, to
narrow that down? (I assume this is Word 2008? did you use a macro for
this in Word 2004?)

Just in case it matters, instead of • as your interim paragraph holder,
maybe try using %%%--that probably doesn't appear naturally in your text
anywhere and should be fine. I'm not very good with Unicode/charset
issues, but I think • is not in the most basic set--it's possible
something is tripping on it, between AppleScript and Word.

The other observation I would make is that there are a lot of settings
in F&R. This script specifically deals with "match sounds like". It's
possible that something else needs to be handled, and that could account
for intermittent results.

Daiya
 
T

Tobias Weber

Daiya Mitchell said:
be a bug with how F&R works on Japanese text. Can you test the script
itself on English/Roman alphabet text and see if it is reliable, to

Did that before coming here: no change

What does help is using Language Register to switch Word back to
English, completely disabling all Japanese features...
narrow that down? (I assume this is Word 2008? did you use a macro for
Yes

this in Word 2004?)

Never touched VB
maybe try using %%%--that probably doesn't appear naturally in your text

Doesn't help
anywhere and should be fine. I'm not very good with Unicode/charset
issues, but I think • is not in the most basic set--it's possible

There is no 'basic' Unicode

It is not an ASCII character, yes
The other observation I would make is that there are a lot of settings

Indeed, even more when Japanese is enabled
in F&R. This script specifically deals with "match sounds like". It's
possible that something else needs to be handled, and that could account
for intermittent results.

Yes, but what ;)
 
D

Daiya Mitchell

Tobias said:
Did that before coming here: no change

What does help is using Language Register to switch Word back to
English, completely disabling all Japanese features...

Okay, sounds like that's where the bug is, then. I'll report it to MS. I
guess you could experiment with handling some of the settings in the
script and see if you get better results, though.
There is no 'basic' Unicode

Yeah, I was referring to most basic charset.

Daiya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top