Update Cross Reference in Word from Excel

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
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.

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.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top