Word VBA superscript

E

erin.sebastian

Hi all,
I have a program that automatically creates a document based on fields
the user has selected in a form. It has the ability to create an
English document and a French document and my question is this:
I have a few date fields and if the user has selected the first of
whatever month i output
1er mai 2005 ( for example ) i want to superscript the er but i am
having a hard time figuring out how to do this. I know once you get the
font property you can apply the superscript property but i don't think
you can access the font property on a string and i can't seem to set my
text as a range or a selection. This is what i've tried (i get errors
with this)

Public Sub frenchScript(ByVal documentRange As Range)

Dim temp As String

temp = "1er"

With documentRange.Find
.Text = temp
.Font.Superscript
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With

End Sub

any help would be wonderful,
THANKS!!
 
H

Helmut Weber

Hi,

like this and in may other ways:

Sub test14()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "1er"
While .Execute
' rDcm.HighlightColorIndex = wdYellow ' for testing
With rDcm.Characters
.Last.Font.Superscript = True
.Last.Previous.Font.Supercript = True
End With
Wend
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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