Hello all,
I want to copy some cell values into a Word document that has a form to fill in. This is what I have done
Code
Sub fillWordLetter()
Dim wd As Object
Dim documentoWord As String
' ################################
' Get some cell values
nombreCajera = ActiveCell.Offset(0, -3).Value
apellidoCajera = ActiveCell.Offset(0, -2).Value
' ################################
' Word Object
Set wd = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wd = CreateObject("Word.Application")
End If
' ################################
' Word Activate
wd.Visible = True
AppActivate wd.Name
' ################################
' Open the file...
With wd
documentoWord = "document.doc"
.ChangeFileOpenDirectory "C:\path\"
.Documents.Open Filename:=documentoWord
' ################################
' ... and try to fill the form
' This doesn't work :-(
.FormFields("Nombre").Result = nombreCajera + " " + apellidoCajera
.PrintOut
End With
' ################################
' Delete the Word Object
Set wd = Nothing
End Sub
Display More
I think that this is kind a Word question, than an Excel one, but I cannot figure why I cannot point to a word "FormField" from Excel. I can write .Selection.TypeText Text:="something" (To an unlocked document of course), or even print with ".PrintOut", but it seems imposible to fill a form! The document is "locked" and it only allow forms to be filled, maybe this could be the problem?
Any help will be much appreciated!!