search and replace with super/subscript

S

slideTFN

I need to create a macro to find and replace the single characters Ú,
Æ and ¿ with the fractions 1/4, 1/2 and 3/4, with the numerators and
the slash character superscripted and the denominator subscripted. I
found a helpful thread from 2 years ago on how to use the Format menu
and Font to apply superscript and subscript. This works on a one-off
basis, but when I record the necessary steps as a macro and try to run
it, I get a run-time error message:

"Run-time error '5843' one of the values passed to this method or
property is out of range"

The debuggers points to the following as the out of range values:

With Selection.Font
.Name = "Times New Roman"
.Size = 0 (problem with this line)
(snip)
.Spacing = 0
.Scaling = 0 (problem with this line)

I have no idea what the values should be or how I set them, and
furthermore I want this macro to work regardless of the font size of
the document I'm using it in. What should I do? Thanks in advance for
any suggestions.
 
B

Beth Rosengard

Are you in Word 2004? If so, you can use the Character Palette to find
those three fractions and skip the workaround. They are Unicode characters
00BC, 00BD and 00BE: 1Ž4, 1Ž2, 3Ž4.


--
***Please always reply to the newsgroup!***

Beth Rosengard
MacOffice MVP

Mac Word FAQ: <http://word.mvps.org/MacWordNew/index.htm>
(If using Safari, hit Refresh once or twice ­ or use another browser.)
Entourage Help Page: <http://www.entourage.mvps.org>
 
P

Paul Berkowitz

Or rather - had you taken your own advice also in Entourage : 1Ž4, 1Ž2, 3Ž4.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
S

slideTFN

I'm in Word 2004. Beth, your suggestion is a good one, except that I
work for a magazine, and way back in 1988 when we first needed to
produce these fractions in copy, we solved the problem with superscript
and subscript and have taken that approach ever since. I'm pretty sure
Unicode characters were not an option in the word-processor we used at
that time, and (not my choice) we still use an OS 9 page layout program
that I think does not support the Unicode fractions in Word. I may be
wrong on this last point. A long-term option, when we switch as long
planned to a more modern page layout program, is to convince my boss
that a new fraction style is OK in our published copy. For now I need
to be able to accomplish the action described in my original post.
Thanks for the suggestion!
 
C

Clive Huggan

Dear [whoever]

I can't help you with a macro to replace your previous one.

The way I would be doing it, now that I know the full scenario (albeit your
fraction characters have not appeared as such in my newsreader) would be:

1. Set up AutoCorrect entries that replace "1/2" et seq. with formatted
superscript fractions, exactly as described on pages 175-176 of "Bend Word
to Your Will", available as a free download from the Word MVPs' website
(http://word.mvps.org/MacWordNew/Bend/BendWord.htm). NOTE: This is not the
same as the more commonly used field-based method of doing fractions. Among
other things, it is much more elegant typographically.

2. Turn off smart cut and paste (Edit menu => Preferences => Edit => Use
smart cut and paste).

3. Replace [the character you have in your e-mail, which I can't read] and
the following space with "1/2" (exactly as shown here, = ASCII, not
formatted), followed by no space.

4. Create a macro that looks for "1/2" (these will still be unformatted) and
adds a space after the "2". This will trigger AutoCorrect to substitute the
typographically elegant fraction.

5. Do likewise for other fractions. Reinstate smart cut and paste if
required (which can easily be automated, of course).

Cheers,

Clive Huggan
Canberra, Australia
(My time zone is 5-11 hours different from the US and Europe, so my
follow-on responses to those regions can be delayed)
============================================================

* A SUGGESTION -- WAIT FOR CONSIDERED ADVICE: If you post a question, keep
re-visiting the newsgroup for several days after the first response comes
in. Sometimes it takes a few responses before the best or complete solution
is proposed; sometimes you'll be asked for further information so that a
better answer can be provided. Good tips about getting the best out of
posting are at http://word.mvps.org/FindHelp/Posting.htm (if you use Safari
you may see a blank page and have to hit the circular arrow icon -- "Reload
the current page" -- a few times).

* AVOID SPAM: To avoid spam directed at contributors of newsgroups, you can
set up a "send-only" dummy e-mail account. Full guidelines are at
http://www.entourage.mvps.org/tips/tip019.html

============================================================
 
C

Clive Huggan

Just reviewing my reply: I probably needed to be clearer re step 4. It would
read better as:

4. Create a macro that looks for "1/2" (these will still be unformatted),
clicks after the "2" and keys a space.

Clive Huggan
============

Dear [whoever]

I can't help you with a macro to replace your previous one.

The way I would be doing it, now that I know the full scenario (albeit your
fraction characters have not appeared as such in my newsreader) would be:

1. Set up AutoCorrect entries that replace "1/2" et seq. with formatted
superscript fractions, exactly as described on pages 175-176 of "Bend Word
to Your Will", available as a free download from the Word MVPs' website
(http://word.mvps.org/MacWordNew/Bend/BendWord.htm). NOTE: This is not the
same as the more commonly used field-based method of doing fractions. Among
other things, it is much more elegant typographically.

2. Turn off smart cut and paste (Edit menu => Preferences => Edit => Use
smart cut and paste).

3. Replace [the character you have in your e-mail, which I can't read] and
the following space with "1/2" (exactly as shown here, = ASCII, not
formatted), followed by no space.

4. Create a macro that looks for "1/2" (these will still be unformatted) and
adds a space after the "2". This will trigger AutoCorrect to substitute the
typographically elegant fraction.

5. Do likewise for other fractions. Reinstate smart cut and paste if
required (which can easily be automated, of course).

Cheers,

Clive Huggan
Canberra, Australia
(My time zone is 5-11 hours different from the US and Europe, so my
follow-on responses to those regions can be delayed)
============================================================

* A SUGGESTION -- WAIT FOR CONSIDERED ADVICE: If you post a question, keep
re-visiting the newsgroup for several days after the first response comes
in. Sometimes it takes a few responses before the best or complete solution
is proposed; sometimes you'll be asked for further information so that a
better answer can be provided. Good tips about getting the best out of
posting are at http://word.mvps.org/FindHelp/Posting.htm (if you use Safari
you may see a blank page and have to hit the circular arrow icon -- "Reload
the current page" -- a few times).

* AVOID SPAM: To avoid spam directed at contributors of newsgroups, you can
set up a "send-only" dummy e-mail account. Full guidelines are at
http://www.entourage.mvps.org/tips/tip019.html

============================================================


I need to create a macro to find and replace the single characters Ú,
Æ and ¿ with the fractions 1/4, 1/2 and 3/4, with the numerators and
the slash character superscripted and the denominator subscripted. I
found a helpful thread from 2 years ago on how to use the Format menu
and Font to apply superscript and subscript. This works on a one-off
basis, but when I record the necessary steps as a macro and try to run
it, I get a run-time error message:

"Run-time error '5843' one of the values passed to this method or
property is out of range"

The debuggers points to the following as the out of range values:

With Selection.Font
.Name = "Times New Roman"
.Size = 0 (problem with this line)
(snip)
.Spacing = 0
.Scaling = 0 (problem with this line)

I have no idea what the values should be or how I set them, and
furthermore I want this macro to work regardless of the font size of
the document I'm using it in. What should I do? Thanks in advance for
any suggestions.
 
K

Klaus Linke

Paul Berkowitz said:
Or rather - had you taken your own advice also in Entourage : 1Z4, 1Z2,
3Z4.

Beth, Paul, shouldn't that be ¼, ½, ¾?
(As you can see, I don't use Entourage <eg>)

Klaus
 
R

Ritika Pathak [MSFT]

Hi,

As your scenarios is related to replacing some text in a document with
super/sub scripted characters, you could also use Find/Replace from Edit
Menu.

You can follow these steps:
- Type the super/sub scripted character you want in the document
- Copy and paste it in "Replace With" text field in Find/Replace dialog
- Type the character you want to replace in "Find What" text field
- Click Replace All

Although this doesn't directly address the macro problem, but could be used
as an alternative solution.

Hope this helps!
Ritika [MSFT]
MacWord Test,
Mac Business Unit, Microsoft


I need to create a macro to find and replace the single characters Ú,
Æ and ¿ with the fractions 1/4, 1/2 and 3/4, with the numerators and
the slash character superscripted and the denominator subscripted. I
found a helpful thread from 2 years ago on how to use the Format menu
and Font to apply superscript and subscript. This works on a one-off
basis, but when I record the necessary steps as a macro and try to run
it, I get a run-time error message:

"Run-time error '5843' one of the values passed to this method or
property is out of range"

The debuggers points to the following as the out of range values:

With Selection.Font
.Name = "Times New Roman"
.Size = 0 (problem with this line)
(snip)
.Spacing = 0
.Scaling = 0 (problem with this line)

I have no idea what the values should be or how I set them, and
furthermore I want this macro to work regardless of the font size of
the document I'm using it in. What should I do? Thanks in advance for
any suggestions.
 

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