Error with EXCEL macro transfering information to a form in WORD

R

Ruth

Hi

I have programmed a macro in EXCEL to transfer the information in a row in
EXCEL to a form previously defined in Word.

The routine I use is below and it is working with the exception of one of
the cells (the one copied to Text3). The problem is the cell in EXCEL
contains a long text and when copied to the form in WORD does not work
because it seems it is expecting to see a String and the information in the
cell does not fit in a String (is much longer). I get in execution an error
because the information is too long. Any work around to this?

I just extracted here (full text below) the way I programmed it.
If wdFF.Name = "Text3" Then
wdFF.Result = Range("T" & fila)
End If

"Text3" is the identifier in the WORD form to which the information has to
be copied.

Dim wordApp, wdFF As Object, wordFile As Object, myFile As String, I,
fila As Integer
myFile = "NEW_FORM.doc"
Set wordApp = CreateObject("Word.Application")
Set wordFile = wordApp.Documents.Open(myFile)
.......
fila = 3
I = 1
For Each wdFF In wordFile.Formfields
If wdFF.Name = "Text1" Then
wdFF.Result = Range("H" & fila)
End If
If wdFF.Name = "Dropdown2" Then
wdFF.DropDown.Value = Left(Range("A" & fila), 1) + 1
End If

If wdFF.Name = "Text3" Then
wdFF.Result = Range("T" & fila)
End If
...................
I = I + 1
Next
wordApp.Quit
Set wordFile = Nothing
Set wordApp = Nothing
End Sub
 

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