VBA to update cross-reference in a word documents

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
Hello all,

I'm using some coding to first, select from drop down form field in a word document based on a select case method.

My question is that in another part of the word document, i have a cross reference to this field and i want to know is how do i update this field using code.

VBA Code:
Dim Wordapp As Word.Application
Dim TPws As Worksheet

Set TPws = ThisWorkbook.Worksheets("Tract Parcels")

Dim wFile As String
wFile = ActiveWorkbook.Path & "\x.docx"
If Dir(wFile) <> "" Then
    Wordapp.Documents.Open (wFile)
    Wordapp.Visible = True
Else
    MsgBox "File does not exists"
    'do actions
End if

Select Case TPws.Cells(rw, "D")
    Case "PVT AGR"
        Wordapp.ActiveDocument.FormFields("DDNOC").DropDown.Value = 2
    Case Else
        Wordapp.ActiveDocument.FormFields("DDNOC").DropDown.Value = 1
End Select

The form field being referenced in the document is title DDNOC. There are two options as of right now. I need the reference field to update based on the value select here.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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