Since I got no answer I can only assume that my problem is trivial,
unanswerable or, most likely, that I did not give enough information. I'll
operate on the assumption
here is a typical call"
Call find_replace_text("&buyers_name", frmInitialdata.txtbuyersname.Text)
Here is the code
Sub find_replace_text(oldtext As String, newtext As String)
'
' find_replace Macro
Set myrange = ActiveDocument.Content
Call Check_Text(newtext)
With myrange.Find
.ClearFormatting
.Text = oldtext
With .Replacement
.Text = newtext
End With
.Execute Replace:=wdReplaceAll, Format:=True
End With
End Sub
' I wrote this sub to check to see if the correct ASCII characters were
being sent. Newstring should have CHR$(13) and CHR$(10) at the end of each
line.
' By stepping through the routine below, I confirmed that both those
characters were present. So this routine is going to be deleted
' So I know that the newtext string has the right content.
'
Sub Check_Text(newtext As String)
Dim text0 As String
Dim text1 As String
Dim index As Integer
text0 = ""
For index = 1 To Len(newtext)
text1 = Mid$(newtext, index, 1)
Select Case Asc(text1)
Case Is = 13
text0 = text0 & Chr(13)
Case 32 To 127
text0 = text0 & text1
Case Else
text1 = text1
End Select
Next index
newtext = text0
End Sub
>I have written a macro to replace specific text with the contents of a
>textbox on a form. If the textbox contains multiple lines then the
[quoted text clipped - 10 lines]
> rickenglish@cox.net tel: fax: mobile: 619-338-9197 619-338-9167
> 619-818-3052 Add me to your address book... Want a signature like this?
Jay Freedman - 02 Nov 2004 22:22 GMT
Hi, Rick,
The problem is that the textbox and the document don't agree on what
constitutes an end-of-line character. The textbox does indeed use Chr$(13) &
Chr$(10). The document wants to see only the Chr$(13), and it displays the
Chr$(10) as a square.
Try this call instead of the one you have:
Call find_replace_text("&buyers_name", _
Replace(frmInitialdata.txtbuyersname.Text, Chr$(10), ""))

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
> Since I got no answer I can only assume that my problem is trivial,
> unanswerable or, most likely, that I did not give enough
[quoted text clipped - 65 lines]
>> 619-818-3052 Add me to your address book... Want a signature like
>> this?