PDA

View Full Version : Solved: string too long



OTWarrior
10-09-2007, 03:58 AM
I keep getting the message "string too long" when trying to import form another file (from table cells into form fields) using my custom procedure:

Public Sub Import_TEST()
Set CurrentDoc = Word.Application.Documents(1)
With Dialogs(wdDialogFileOpen)
If .Display <> -1 Then
Exit Sub
Else
Set BrowseFile = Word.Application.Documents.Open _
(WordBasic.FileNameInfo$(.Name, 1), , , , , , , , , , , False)
End If

CurrentDoc.FormFields("Form1").Result = _
LineFeedStripper(Replace((BrowseFile.Tables(7).Cell(5, 5)), "", ""))
end with
end sub


Now the cell contains more than 256 characters, and I need to import it (along with the rest of the document). Is there a data type that can accept more than 256 characters? or a better way of importing large ammounts of text to be inputting into a form field?

TonyJollans
10-09-2007, 05:16 AM
Yes, this is one of Word's oddities. See http://word.mvps.org/FAQs/MacrosVBA/SetLongFmFldResult.htm

fumei
10-09-2007, 06:36 AM
You can also Select the formfield and "type" in the long string. This is the workaround that Microsoft itself publishes. The Word MVP solution is, generally speaking, better.

OTWarrior
10-09-2007, 06:59 AM
I had already found that MVP code and tried it before I posted, however it did not work....


....it was only when I looked at it again (after you posted the link) that i realised I forgot to change:

CurrentDoc.FormFields()

to

CurrentDoc.Bookmarks()

.....whoops :rotlaugh: