Home |
Search |
Today's Posts |
#1
|
|||
|
|||
replacing text in templates
I have a template with bookmarks. In a vb macro I replace the bookmark with
text. I need to know a good technique for doing this. 1. when I use 'times new roman' which is a variable width font counting characters in the bookmark & inserting text has its problem 2. Tried to use tabs in the bookmark but they count for one character when they may replace lots of characters. So what's a good solution to truncate too long strings of text & keep the resulting text with the same positions of the benchmark. TIA -- _________________________________ in Christ's matchless name 73 ted & colleen n6trf kc6rue |
#2
|
|||
|
|||
"ted medin" wrote in message ... I have a template with bookmarks. In a vb macro I replace the bookmark with text. I need to know a good technique for doing this. 1. when I use 'times new roman' which is a variable width font counting characters in the bookmark & inserting text has its problem 2. Tried to use tabs in the bookmark but they count for one character when they may replace lots of characters. So what's a good solution to truncate too long strings of text & keep the resulting text with the same positions of the benchmark. TIA would you believe bookmark I supose showing some of the code might help: This is what i use to figure the size the bookmark can take: act_name = Trim(rstProj![activity name]) & " " With ActiveDocument.Bookmarks("proj_namep1") If Len(act_name) (.End - .Start) Then act_namep1 = Left(act_name, (.End - .Start)) act_namep2 = Mid(act_name, (.End - .Start + 1)) If Left(act_namep2, 1) = Space(1) Then ' we have a good break already Else For I = (.End - .Start) To 10 Step -1 If Mid(act_namep1, I, 1) = Space(1) Then act_namep2 = Right(act_namep1, Len(act_namep1) - I) & act_namep2 act_namep1 = Left(act_namep1, I) & Space(10) GoTo gotsp ' found a space & shifted appropiately End If Next I If Right(act_namep1, 1) Space(1) Then act_namep2 = Right(act_namep1, 1) & act_namep2 act_namep1 = Left(act_namep1, Len(act_namep1) - 1) & "-" End If End If Else act_namep1 = act_name act_namep2 = " " And this is how i stuff the text in the bookmark Public Sub replacebookmarktext(strbkmk As String, strRep As String) With ActiveDocument.Bookmarks(strbkmk).Range .Text = Left(strRep & Space(1), ActiveDocument.Bookmarks(strbkmk).End _ - ActiveDocument.Bookmarks(strbkmk).Start) .Select End With ActiveDocument.Bookmarks.Add strbkmk, Selection.Range End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mirror Text Box | Formatting Long Documents | |||
help, problem with text field in word 2003 | Microsoft Word Help | |||
Excel worksheet in Word linked text boxes | Page Layout | |||
Outline | Page Layout | |||
Templates in too many languages. Only need English. | Microsoft Word Help |