Transfer a string longer than 255 chr from an access form to word

G

GuideDogsJoe

I have a form in access, I want to transfer fields within the form to a word
doc. I'm using a command button on the access form to open the word doc and
move the data to word, everything works. I'm able to move 25 of the 26 field
of data to the word doc except the memo field, since the field contains more
than 255 characters the data isn't moveing over to the defined txt field on
the word doc. Any suggestions on how I can move over this large string of
text.
Thanks
 
A

Alex Dybenko

Hi,
if you using find method - then you can use Selection object, here how it
works at me:

Public Sub ReplaceText(strFindWhat As String, strReplaceTo As String)

If Len(strReplaceTo) < 250 Then
With m_wdDocument.Content.Find
.Execute FindText:=strFindWhat
If .found Then
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Execute FindText:=strFindWhat, _
ReplaceWith:=strReplaceTo, _
Format:=True, Replace:=2 'wdReplaceAll
End If
End With
Else
'strReplaceTo could be only 255 long, here another approach:
m_wdDocument.Range(0, 0).select
With m_wdApplication
With .Selection.Find
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Text = strFindWhat
Do While .Execute
m_wdApplication.Selection = strReplaceTo
m_wdDocument.Range(0, 0).select
Loop
End With
End With
End If
End Sub

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top