From: lallen on 27 May 2010 18:01 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
From: lallen on 28 May 2010 19:14 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 "Graham Mayor" wrote: > I suggest something along the lines of > > 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 > oRng.Case = wdTitleWord > Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & "a").Range > oRng.Text = txtTitleA > oRng.Case = wdTitleWord > Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & "b").Range > oRng.Text = txtTitleB > oRng.Case = wdTitleWord > Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & "c").Range > oRng.Text = txtTitleC > oRng.Case = wdTitleWord > Next intLoop1 > End With > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > > "lallen" wrote: > > > 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
From: Doug Robbins - Word MVP on 28 May 2010 23:56 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 "lallen" <lallen(a)discussions.microsoft.com> wrote in message news:12453254-DECD-4FFE-9305-181120ADEABF(a)microsoft.com... > 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 > > "Graham Mayor" wrote: > >> I suggest something along the lines of >> >> 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 >> oRng.Case = wdTitleWord >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & >> "a").Range >> oRng.Text = txtTitleA >> oRng.Case = wdTitleWord >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & >> "b").Range >> oRng.Text = txtTitleB >> oRng.Case = wdTitleWord >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & >> "c").Range >> oRng.Text = txtTitleC >> oRng.Case = wdTitleWord >> Next intLoop1 >> End With >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> >> >> "lallen" wrote: >> >> > 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
From: lallen on 29 May 2010 16:15 Thanks Doug. That works like a charm. ....Larry "Doug Robbins - Word MVP" wrote: > 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 > > "lallen" <lallen(a)discussions.microsoft.com> wrote in message > news:12453254-DECD-4FFE-9305-181120ADEABF(a)microsoft.com... > > 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 > > > > "Graham Mayor" wrote: > > > >> I suggest something along the lines of > >> > >> 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 > >> oRng.Case = wdTitleWord > >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & > >> "a").Range > >> oRng.Text = txtTitleA > >> oRng.Case = wdTitleWord > >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & > >> "b").Range > >> oRng.Text = txtTitleB > >> oRng.Case = wdTitleWord > >> Set oRng = .Bookmarks("Title" & Right("0" & intLoop1, 2) & > >> "c").Range > >> oRng.Text = txtTitleC > >> oRng.Case = wdTitleWord > >> Next intLoop1 > >> End With > >> > >> -- > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> Graham Mayor - Word MVP > >> > >> My web site www.gmayor.com > >> Word MVP web site http://word.mvps.org > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> > >> > >> > >> "lallen" wrote: > >> > >> > 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 >
|
Pages: 1 Prev: Toggle button code to insert user response into template Next: Anyone else? |