PDA

View Full Version : Solved: format one char only in a string



mike009
03-03-2009, 06:13 AM
Hi,

I have a bookmark, and inside this book mark i want to add the following

"xxx-xxxxx-xx - bank name"

But the clients want that the "dash" before bank is longer

there is no longer dash in the keyboard, so what i want to do is shange the size of the dash before bank.
some thing like this

const dash = "-"
<here code to change the font size of "dash" from 7 to 11>
"xxx-xxxxx-xx " & datsh & " bank name"

any idea?

fumei
03-03-2009, 09:34 AM
Use .Find of the range of the bookmark, and then a character style for the found dash. However, as you have two previous dashes, you will have to make sure you only process the third one. Here is one way (assuming the bookmark is named "Bank", and there is a Character Style named "BigDash":

Sub ChangeDash()
Dim r As Range
Dim j As Long
Set r = ActiveDocument.Bookmarks("Bank").Range
With r.Find
Do While .Execute(Findtext:="-", _
Forward:=True) = True
If j = 2 Then
r.Style = "BigDash"
End If
j = j + 1
Loop
End With
End Sub

mike009
03-04-2009, 03:44 AM
Thank you fumei

I found this solution
"xxx-xxxxx-xx " & char(151) & " bank name"

it works fine,

thank you

fumei
03-04-2009, 12:17 PM
It works fine?

Really. Glad to hear it. It sure does not for me. char is not valid. Chr() is, but not char().

Further, even changing it to Chr(151), while it does indeed put in a longer dash, it certainly does not change the font size from 7 to 11.

However, if it works for you, then...it works for you. thanks for marking it solved.