change font size of first character

L

lallen

I have a template that allows users to print business cards. It displays a
form where they enter their name and three other lines of text. I would like
to increase the font size of the first character in each word if the user
enters the text in upper case.

The code I'm using to capture the text from the form is:

With ActiveDocument
For intLoop1 = 1 To 10
.Bookmarks("Name" & Right("0" & intLoop1, 2)).Range.InsertBefore txtName
.Bookmarks("Title" & Right("0" & intLoop1, 2) & "a").Range.InsertBefore
xtTitleA
.Bookmarks("Title" & Right("0" & intLoop1, 2) & "b").Range.InsertBefore
txtTitleB
.Bookmarks("Title" & Right("0" & intLoop1, 2) & "c").Range.InsertBefore
txtTitleC
Next intLoop1
End With

How do I go about changing the font size of selective characters in each
string?

Thanks for any help you can provide. ...Larry
 
L

lallen

Thanks Graham, but that's not exactly what I was looking for. I want to
change the font size, not the case, of the first letter of each word. I'm not
sure if it's doable or not.

....Larry
 
D

Doug Robbins - Word MVP

Use

Dim intLoop1 As Long
Dim txtName As String
Dim txtTitleA As String
Dim txtTitleB As String
Dim txtTitleC As String
Dim oRng As Range
With ActiveDocument
For intLoop1 = 1 To 10
Set oRng = .Bookmarks("Name" & Right("0" & intLoop1, 2)).Range
oRng.Text = txtName
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"a").Range
oRng.Text = txtTitleA
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"b").Range
oRng.Text = txtTitleB
If oRng.Case = 1 Then 'The text is upper case, but it could also
include numerals
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"c").Range
oRng.Text = txtTitleC
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Next intLoop1
End With


Or, you may want to check the case of each word in the range in case there
is a mixture

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
L

lallen

Thanks Doug. That works like a charm.

....Larry

Doug Robbins - Word MVP said:
Use

Dim intLoop1 As Long
Dim txtName As String
Dim txtTitleA As String
Dim txtTitleB As String
Dim txtTitleC As String
Dim oRng As Range
With ActiveDocument
For intLoop1 = 1 To 10
Set oRng = .Bookmarks("Name" & Right("0" & intLoop1, 2)).Range
oRng.Text = txtName
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"a").Range
oRng.Text = txtTitleA
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"b").Range
oRng.Text = txtTitleB
If oRng.Case = 1 Then 'The text is upper case, but it could also
include numerals
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) &
"c").Range
oRng.Text = txtTitleC
If oRng.Case = 1 Then
For i = 1 To oRng.Words.Count
With oRng.Words(1)
If .Case <> -1 Then 'The word is numeric
With .Characters(1).Font
.Size = .Size + 2 'Increase size by 2 points,
vary to suit
End With
Else 'Increase the size of all numerals
With .Font
.Size = .Size + 2
End With
End If
End With
Next i
End If
Next intLoop1
End With


Or, you may want to check the case of each word in the range in case there
is a mixture

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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