R
Ruth
Hi!!
I am trying to use a macro to fill in a field in a form with a paragraph I
copy from an EXCEL cell. The problem is that this paragrph has more than 255
characters so it doesn't seem to work directly. I have seen some article that
sugest to use the clipboard as a way to overcome this problem. Then, the code
I have programmed is as follows:
Range("T"&fila) returns the paragraph from the EXCEL cell.
wdFF is defined as Object in wordFile.Formfields.
rngx is defined as Range
If Len(Range("T" & fila)) > 255 Then
wdFF.Result = Left$(Range("T" & fila), 250)
MyDataObj.SetText ""
MyDataObj.PutInClipboard
MyDataObj.SetText Mid$(Range("T" & fila), 256)
MyDataObj.PutInClipboard
Set rngx = wdFF.Range
rngx.GoTo
rngx.Select
With wordFile.Selection
.Collapse wdCollapseEnd
.Paste
End With
Else
wdFF.Result = Range("T" & fila)
End If
The macro works fine until it arrives to the sentence "Set rngx =
wdFF.Range" where it stops and says that formats are not compatible (rngx is
defined as a range). Any idea of how to solve the problems with the code?
Does the rest of the code for the macro look fine?
I am trying to use a macro to fill in a field in a form with a paragraph I
copy from an EXCEL cell. The problem is that this paragrph has more than 255
characters so it doesn't seem to work directly. I have seen some article that
sugest to use the clipboard as a way to overcome this problem. Then, the code
I have programmed is as follows:
Range("T"&fila) returns the paragraph from the EXCEL cell.
wdFF is defined as Object in wordFile.Formfields.
rngx is defined as Range
If Len(Range("T" & fila)) > 255 Then
wdFF.Result = Left$(Range("T" & fila), 250)
MyDataObj.SetText ""
MyDataObj.PutInClipboard
MyDataObj.SetText Mid$(Range("T" & fila), 256)
MyDataObj.PutInClipboard
Set rngx = wdFF.Range
rngx.GoTo
rngx.Select
With wordFile.Selection
.Collapse wdCollapseEnd
.Paste
End With
Else
wdFF.Result = Range("T" & fila)
End If
The macro works fine until it arrives to the sentence "Set rngx =
wdFF.Range" where it stops and says that formats are not compatible (rngx is
defined as a range). Any idea of how to solve the problems with the code?
Does the rest of the code for the macro look fine?