Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Henry Stock[_3_] Henry Stock[_3_] is offline
external usenet poster
 
Posts: 5
Default Peculiar search and Replace

I wonder if anyone can help me with the following search and replace.

I want to replace the character string CO2 with the equivalent string
except with the 2 subscripted. I tried highlighting the 2 in the
replacement string and then selecting special formating and choosing a
subscripted font, but that just resulted in the entire string being
subscripted.

I am using Word 2007




  #2   Report Post  
Posted to microsoft.public.word.newusers
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Peculiar search and Replace

Format the string as desired in your document and copy it to the Clipboard,
then use ^c (Clipboard contents) as your "Replace with" text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
I wonder if anyone can help me with the following search and replace.

I want to replace the character string CO2 with the equivalent string
except with the 2 subscripted. I tried highlighting the 2 in the
replacement string and then selecting special formating and choosing a
subscripted font, but that just resulted in the entire string being
subscripted.

I am using Word 2007





  #3   Report Post  
Posted to microsoft.public.word.newusers
Henry Stock[_3_] Henry Stock[_3_] is offline
external usenet poster
 
Posts: 5
Default Peculiar search and Replace

Sorry, but that did not work either. The old CO2s are still in
normal font


"Suzanne S. Barnhill" wrote in message
...
Format the string as desired in your document and copy it to the
Clipboard, then use ^c (Clipboard contents) as your "Replace with"
text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
I wonder if anyone can help me with the following search and replace.

I want to replace the character string CO2 with the equivalent
string except with the 2 subscripted. I tried highlighting the 2 in
the replacement string and then selecting special formating and
choosing a subscripted font, but that just resulted in the entire
string being subscripted.

I am using Word 2007








  #4   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Peculiar search and Replace

Hi Henry,

You're asking for more than the standard Find/Replace functions allow.

The following macro will search the active document for chemical formulae (represented by numbers preceded by a letter or a right
bracket) and subscript just the numbers. Unless you're working with isotopes, the results should be correct - you'll need to apply
the isotope superscripting yourself (if the numbers are already superscripted, they'll be left alone).

If your document has other alphanumeric strings in which a non-superscripted number follows a letter (eg Table cell references), you'll
need to select only the range(s) containing the text to be converted and answer 'No' to the prompt.

Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1, End:=Selection.End)
If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
If fRng.Font.Superscript = False Then fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Henry Stock" wrote in message ...
I wonder if anyone can help me with the following search and replace.

I want to replace the character string CO2 with the equivalent string except with the 2 subscripted. I tried highlighting the 2
in the replacement string and then selecting special formating and choosing a subscripted font, but that just resulted in the
entire string being subscripted.

I am using Word 2007





  #5   Report Post  
Posted to microsoft.public.word.newusers
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Peculiar search and Replace

It absolutely works here. See if you're following all the right steps.

1. In the document, select one instance of CO2 and subscript the 2.

2. Select the result and copy it (Ctrl+C).

3. Open the Replace dialog (Ctrl+H).

4. In the "Find what" box, type "CO2" (without the quotation marks).

5. In the "Replace with" box, type "^c" (without the quotation marks).
Alternatively, click More, place the insertion point in the "Replace with
box" and click Special and choose "Clipboard Contents," which will insert ^c
for you.

6. Make sure that there is no formatting indicated on either box.

7. Replace All.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
Sorry, but that did not work either. The old CO2s are still in normal
font


"Suzanne S. Barnhill" wrote in message
...
Format the string as desired in your document and copy it to the
Clipboard, then use ^c (Clipboard contents) as your "Replace with" text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
I wonder if anyone can help me with the following search and replace.

I want to replace the character string CO2 with the equivalent string
except with the 2 subscripted. I tried highlighting the 2 in the
replacement string and then selecting special formating and choosing a
subscripted font, but that just resulted in the entire string being
subscripted.

I am using Word 2007











  #6   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default Peculiar search and Replace

Suzanne S. Barnhill wrote:
Format the string as desired in your document and copy it to the
Clipboard, then use ^c (Clipboard contents) as your "Replace with" text.


"Henry Stock" wrote:
Sorry, but that did not work either. The old CO2s are still in normal
font


Strange... Did you really format the CO2 with subscripted "2", then selected
and copied it to the clipboard, then used
Find what: CO2
Replace with: ^c
?

Another way to do it... Use the font character for the subscripted 2
(Unicode: 2082):
Find what: CO2
Replace with: CO2

You can insert the 2 (in the Find dialog, as in the document) by typing the
code 2082 and then Alt+X.

Regards,
Klaus

  #7   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default Peculiar search and Replace

[Sorry, the subscripted 2 didn't make it. I posted the same text in the test
group, and it did show.
No idea why... One more try €” and if it doesn't work now, I give up.]

Another way to do it... Use the font character for the subscripted 2
(Unicode: 2082):

–º Find what: CO2
–º Replace with: CO‚‚
(In €œReplace with€, it should be the subscripted 2)

You can insert the subscripted ‚‚ (in the Find dialog, as in the document) by
typing the code 2082 and then Alt+X.

Klaus

  #8   Report Post  
Posted to microsoft.public.word.newusers
Henry Stock[_3_] Henry Stock[_3_] is offline
external usenet poster
 
Posts: 5
Default Peculiar search and Replace

Okay, It worked the second time. I screwed up on inserting the ^c the
first time.
Thank you Suzanne.

"Suzanne S. Barnhill" wrote in message
...
It absolutely works here. See if you're following all the right steps.

1. In the document, select one instance of CO2 and subscript the 2.

2. Select the result and copy it (Ctrl+C).

3. Open the Replace dialog (Ctrl+H).

4. In the "Find what" box, type "CO2" (without the quotation marks).

5. In the "Replace with" box, type "^c" (without the quotation marks).
Alternatively, click More, place the insertion point in the "Replace
with box" and click Special and choose "Clipboard Contents," which
will insert ^c for you.

6. Make sure that there is no formatting indicated on either box.

7. Replace All.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
Sorry, but that did not work either. The old CO2s are still in
normal
font


"Suzanne S. Barnhill" wrote in message
...
Format the string as desired in your document and copy it to the
Clipboard, then use ^c (Clipboard contents) as your "Replace with"
text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Henry Stock" wrote in message
...
I wonder if anyone can help me with the following search and
replace.

I want to replace the character string CO2 with the equivalent
string
except with the 2 subscripted. I tried highlighting the 2 in the
replacement string and then selecting special formating and
choosing a
subscripted font, but that just resulted in the entire string being
subscripted.

I am using Word 2007












Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Insert, Search and Replace, Modify Document Margins instant000 Formatting Long Documents 2 October 26th 09 09:34 PM
Search and replace - how to Benjamin Barrett Microsoft Word Help 6 December 30th 07 01:05 AM
search and replace 1) and 2)...12) Brent Formatting Long Documents 2 July 4th 07 06:19 AM
Search and Replace Jackie Formatting Long Documents 6 October 24th 05 09:30 AM
search and replace Tweedy Microsoft Word Help 1 February 10th 05 11:30 AM


All times are GMT +1. The time now is 04:22 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"