VBA to update cross-reference in a word documents

zoog25

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

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Watch MrExcel Video

Forum statistics

Threads
1,122,744
Messages
5,597,884
Members
414,185
Latest member
tarun19954

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
Top