-
too long string
i am getting "too long string" error from the following code from line with exclamation mark. In this textbox i am typing the text which is about 3 to 5 lines. how can i get rid of this error
Private Sub cmdDoc_Click()
Dim wordapp As Word.Application
Dim thisdoc As Document
Dim thisrange As Range
Set wordapp = CreateObject("word.application")
If wordapp Is Nothing Then
MsgBox "could notstart word"
End If
wordapp.Documents.Open ("C:\documents and settings\administrator\application data\microsoft\templates\C-00.dot")
Set thisdoc = wordapp.ActiveDocument
thisdoc.FormFields(1).Result = txtName.Text
thisdoc.FormFields(2).Result = txtFNo.Text
thisdoc.FormFields(3).Result = txtRef.Text
thisdoc.FormFields(4).Result = txtNo.Text
thisdoc.FormFields(5).Result = txtSite.Text
thisdoc.FormFields(6).Result = txtMic.Text ??????
thisdoc.FormFields(7).Result = txtDiag.Text
please help me
-
Re: too long string
2-3 lines I am guessing is over 255 characters long in your case: Some info from msdn: http://support.microsoft.com/default...b;en-us;181110
-
Re: too long string
I dont see how MS thinks that removing characters to make it fit to 255 is a "workaround" :rolleyes:
-
Re: too long string
a real work around is to Redim an array of strings
Code:
Dim Lenght as long, Count as Long
Dim Arr() as String
Length = len(YourObjetsText)
Redim Arr(Length/255)
for Count = 0 to Length
Arr(Count) = mid$(YourObjetsText,Count* 255,255)
next