Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Bjk Bjk is offline
external usenet poster
 
Posts: 1
Default Doing Character Replace


I have the character sequence "a2M".

I want to do a replace of this in my document (a hundred instances at
least) in which 'a' becomes the alpha character (Symbol font most likely)
and '2' is subscripted.

But if I set 'a2M' for symbol font, EVERYTHING becomes symbol font. And if
I try to set just '2' for subscripting, every character is subscripted.

How is this done?
  #2   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Doing Character Replace

If you mean you wish to replace a2M with a formatted version then copy the
manually formatted version to the clipboard and replace a2M with ^c

If however you wish to replace sequences *like* a2M with formatted versions
of them you are going to need a macro - something like the following. Add
case statements for each first character's replacement. The second character
is subscripted and the third ignored.

Dim oRng As Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.Text = ""
.Replacement.ClearFormatting
Do While .Execute("[a-z][0-9][A-Z]", _
MatchWildcards:=True)
Set oRng = Selection.Range
Select Case oRng.Characters(1)
Case "a"
oRng.Characters(1).Text = Chr(97)
oRng.Characters(1).Font.name = "Symbol"
Case "b"
oRng.Characters(1).Text = Chr(98)
oRng.Characters(1).Font.name = "Symbol"
'etc
Case Else
End Select
oRng.Characters(2).Font.Subscript = True
Loop
End With
End With

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"Bjk" wrote in message
...

I have the character sequence "a2M".

I want to do a replace of this in my document (a hundred instances at
least) in which 'a' becomes the alpha character (Symbol font most likely)
and '2' is subscripted.

But if I set 'a2M' for symbol font, EVERYTHING becomes symbol font. And
if
I try to set just '2' for subscripting, every character is subscripted.

How is this done?



  #3   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Doing Character Replace

Hi Bjk,

You could do it with a macro like:

Sub ApplySuperscriptNumbers()
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, "Number Superscripter")
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,}[A-Za-z]"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1, End:=Selection.End - 1)
If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Superscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub

Note: As coded, the macro will only work with numbers (of any length) between two or more letters. If that's not quite what you
require, post back.

--
Cheers
macropod
[Microsoft MVP - Word]


"Bjk" wrote in message ...

I have the character sequence "a2M".

I want to do a replace of this in my document (a hundred instances at
least) in which 'a' becomes the alpha character (Symbol font most likely)
and '2' is subscripted.

But if I set 'a2M' for symbol font, EVERYTHING becomes symbol font. And if
I try to set just '2' for subscripting, every character is subscripted.

How is this done?


  #4   Report Post  
Posted to microsoft.public.word.newusers
Pamelia Caswell via OfficeKB.com Pamelia Caswell via OfficeKB.com is offline
external usenet poster
 
Posts: 468
Default Doing Character Replace

Correct the "a2M" in one place in your document and copy it. In the find
what box, type a2M. In the replace with box type ^c. The "^c" is the code
for the contents of the clipboard.

Pam


Bjk wrote:
I have the character sequence "a2M".

I want to do a replace of this in my document (a hundred instances at
least) in which 'a' becomes the alpha character (Symbol font most likely)
and '2' is subscripted.

But if I set 'a2M' for symbol font, EVERYTHING becomes symbol font. And if
I try to set just '2' for subscripting, every character is subscripted.

How is this done?


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...neral/200912/1

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
Find and Replace Character Karen Microsoft Word Help 2 May 13th 09 06:23 PM
replace a special character Ela New Users 3 July 3rd 08 02:22 PM
Find and replace a character [email protected] Microsoft Word Help 1 September 27th 07 11:39 AM
replace @ character in word Howzitgoing Microsoft Word Help 4 January 21st 05 10:14 PM
Designating "Any Character" in Replace Dialog Joseph N. Microsoft Word Help 3 December 7th 04 05:36 AM


All times are GMT +1. The time now is 09:10 AM.

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"