Hello all,
I have an excel spreadsheet that i have added coding to fill out a word document. The current coding fills in a few text fields throughout the document. My issues is that there are a few points in the document i have filled with Cross Reference fields. The problem is when i run my macro, it fills in all the fields, but all the Cross Reference fields, don't changes. Can you please let me know what i need to add to my current code in order have all reference fields update.
Thank you for any assistance you can provide.
I have an excel spreadsheet that i have added coding to fill out a word document. The current coding fills in a few text fields throughout the document. My issues is that there are a few points in the document i have filled with Cross Reference fields. The problem is when i run my macro, it fills in all the fields, but all the Cross Reference fields, don't changes. Can you please let me know what i need to add to my current code in order have all reference fields update.
Code:
Sub DRIMPAGR(rw As Long)
'Disable other sheet Events
Application.EnableEvents = False
Dim Wordapp As Word.Application
Dim Location As Variant
Dim lrow As Long
Set FMws = ThisWorkbook.Worksheets("Final Map")
Set Conws = ThisWorkbook.Worksheets("Contact")
Set Wordapp = CreateObject("Word.Application")
Dim wFile As String
wFile = ActiveWorkbook.Path & "\Agreements\Improvement.Agr-2Party.docx"
If Dir(wFile) <> "" Then
Wordapp.Documents.Open (wFile)
Wordapp.Visible = True
Else
MsgBox "File does not exists"
'do actions
End If
'Project Entry
If FMws.Cells(rw, "C").Value < 10000 Then
If FMws.Cells(rw, "D").Value <> "" Then
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Tract " & FMws.Cells(rw, "C").Value & " Unit " & FMws.Cells(rw, "D").Value
Else
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Tract " & FMws.Cells(rw, "C").Value
End If
Else
If FMws.Cells(Target, "G").Value <> "" Then
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Parcel Map " & NOCws.Cells(rw, "C").Value & " Phase " & NOCws.Cells(rw, "D").Value
Else
Wordapp.ActiveDocument.FormFields("TXProject").Result = "Parcel Map " & NOCws.Cells(rw, "C").Value
End If
End If
'Developer Name Information
Wordapp.ActiveDocument.FormFields("TXDeveloper").Result = FMws.Cells(rw, "G").Value
'Developer Entity Type
ContactNoc = IMPContFD(rw)
Wordapp.ActiveDocument.FormFields("TXEntity").Result = Conws.Cells(ContactNoc, "K").Value
'Planning Commission Date
Wordapp.ActiveDocument.FormFields("TXCouncilDate").Result = Format(FMws.Cells(rw, "K").Value, "mmmm dd, yyyy")
'Section 12.2 Contact Info
Wordapp.ActiveDocument.FormFields("TXAddress").Result = Conws.Cells(ContactNoc, "G").Value ' Addresss
Wordapp.ActiveDocument.FormFields("TXCSZ").Result = Conws.Cells(ContactNoc, "H").Value & ", " & Conws.Cells(ContactNoc, "I").Value & " " & Conws.Cells(ContactNoc, "J").Value 'City, State, Zip Entry
Wordapp.ActiveDocument.FormFields("TXPhoneNumber").Result = "(" & Conws.Cells(ContactNoc, "E").Value & ") " & Conws.Cells(ContactNoc, "F").Value 'Phone Number Entry
Wordapp.ActiveDocument.FormFields("TXEmail").Result = Conws.Cells(ContactNoc, "N").Value 'Email Address
'Tax ID # Entry
Wordapp.ActiveDocument.FormFields("TXTaxNumber").Result = Conws.Cells(ContactNoc, "L").Value 'Tax ID #
'Corporation Check
If Conws.Cells(ContactNoc, "M").Value = "Yes" Then
Wordapp.ActiveDocument.FormFields("CKYes").CheckBox.Value = True
Else
Wordapp.ActiveDocument.FormFields("CKNo").CheckBox.Value = True
End If
'Review Message
MsgBox ("Please review Agreement Before Sending it to Engineer.")
FMws.Cells(rw, "X").Value = "X"
Application.EnableEvents = True
End Sub
Thank you for any assistance you can provide.