Reply
 
Thread Tools Display Modes
  #1   Report Post  
ted medin
 
Posts: n/a
Default 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   Report Post  
ted medin
 
Posts: n/a
Default


"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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mirror Text Box [email protected] Formatting Long Documents 1 January 24th 05 08:02 PM
help, problem with text field in word 2003 Salvatore Microsoft Word Help 1 January 21st 05 04:40 PM
Excel worksheet in Word linked text boxes Eduardo Oliveira Page Layout 0 January 6th 05 12:23 AM
Outline Renee Hendershott Page Layout 2 December 25th 04 03:49 PM
Templates in too many languages. Only need English. capt_dalton Microsoft Word Help 0 December 2nd 04 11:29 PM


All times are GMT +1. The time now is 01:58 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"