Text from vba text box (>2000 characters) to a Word bookmard 
Author Message
 Text from vba text box (>2000 characters) to a Word bookmard

I have an access memo field loaded into a Visual Basic text box.  The text
box contain about 2100 characters so I am trying to move them in 255 blocks.
I have tried bookmark points and formfields, inserting before and inserting
after, but the results are always scrambled.  The contents of each 255
character block is correct but the blocks are out of order.  Here is the
section of code I use:

If Len(frmTab13.Text1.Text) > 255 Then
        ActiveDocument.Unprotect
        Dim strLen As Long
        lStart = 1
'        strLen = 0
    Do While lStart < Len(frmTab13.Text1.Text)
        xStr = ""
        xStr = Mid$(frmTab13.Text1.Text, lStart, 255)
        Selection.GoTo what:=wdGoToBookmark, Name:="Minutes"
'        Selection.InsertAfter xStr
        oWD.FormFields("Minutes").Result = xStr
        lStart = lStart + 255
    Loop
Else
      oWD.FormFields("Minutes").Result = frmTab13.Text1.Text = ""
End If
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Thanks in advance for any help, Vik



Wed, 17 Dec 2003 12:07:39 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
Sorry, I forgot to mention that I use vb6, Access97, and Word8.  Thanks,
Vik.


Thu, 18 Dec 2003 02:10:53 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
What about:

Selection.InsertAfter frmTab13.Text1

..or have you a particular reason for shifting 255 chrs at a time ?


Quote:
> I have an access memo field loaded into a visual basic text box.  The text
> box contain about 2100 characters so I am trying to move them in 255
blocks.
> I have tried bookmark points and formfields, inserting before and
inserting
> after, but the results are always scrambled.  The contents of each 255
> character block is correct but the blocks are out of order.  Here is the
> section of code I use:

> If Len(frmTab13.Text1.Text) > 255 Then
>         ActiveDocument.Unprotect
>         Dim strLen As Long
>         lStart = 1
> '        strLen = 0
>     Do While lStart < Len(frmTab13.Text1.Text)
>         xStr = ""
>         xStr = Mid$(frmTab13.Text1.Text, lStart, 255)
>         Selection.GoTo what:=wdGoToBookmark, Name:="Minutes"
> '        Selection.InsertAfter xStr
>         oWD.FormFields("Minutes").Result = xStr
>         lStart = lStart + 255
>     Loop
> Else
>       oWD.FormFields("Minutes").Result = frmTab13.Text1.Text = ""
> End If
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

> Thanks in advance for any help, Vik



Thu, 18 Dec 2003 04:45:37 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
Word will only allow 255 characters to be moved at one time.  That's why the
loop and 255 chars per loop.  Thanks for the reply and the suggestion, Vik.


Thu, 18 Dec 2003 05:47:08 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
It works for me, i just transefered 840 char string this way - I have Word
97 no mods


Quote:
> Word will only allow 255 characters to be moved at one time.  That's why
the
> loop and 255 chars per loop.  Thanks for the reply and the suggestion,
Vik.



Thu, 18 Dec 2003 08:03:18 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
Let me explain a little more about what I am doing.  I have a text box on a
vb form and the text box contains about 2000 chrs.  Programatically, I want
to print that text in a Word field identified by a bookmark using the format
"oWD.FormFields("A1Write").Result = frmTab1.MEB3.Text" and that works well
until frmTab1.MEB3.Text has more than 255 chrs.  I will try insertafter and
insert before again and see what happens.  Thanks again for your help, Vik.


Thu, 18 Dec 2003 09:43:24 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
Hi Vik,

Put

ActiveDocument.Bookmarks("Minutes").Range.Select

before the Do While loop

and then in the loop use

Selection.InsertAfter xStr
Selection.Collapse Direction: = wdCollapseEnd

in place of

        Selection.GoTo what:=wdGoToBookmark, Name:="Minutes"
'        Selection.InsertAfter xStr
        oWD.FormFields("Minutes").Result = xStr

Please post any follow-up or new questions to the Newsgroups so that others
may benefit therefrom or contribute thereto.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> Word will only allow 255 characters to be moved at one time.  That's why
the
> loop and 255 chars per loop.  Thanks for the reply and the suggestion,
Vik.



Thu, 18 Dec 2003 11:13:59 GMT  
 Text from vba text box (>2000 characters) to a Word bookmard
Thanks, that was exactly what I needed.
Vik


Fri, 19 Dec 2003 10:25:03 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. using VB text boxes data but not text boxes in word 2000

2. Size text box to fit text in Word 2000

3. Inserting Text in Front of Footnotes in VBA - Word 2000

4. Word 2000 VBA - reading and writing text file

5. spell check text box in word 2000 form

6. Columns in List box, when inserting text from text box (VBA)

7. Formatted Word 2000 text in SQL 2000

8. Rich Text Box SelStart with text > 32Kbytes

9. rich text box SelStart with text > 32K

10. Formatted Word 2000 text in SQL 2000

11. Text box text on new page text box

12. Trouble with text boxes in VBA for Word.

 

 
Powered by phpBB® Forum Software