Word VBA updating a 'Field'

On a Word document I need to programatically update (what looks like a) Field with VBA. But I'm not sure whether they are Fields, as Fields have curly brackets, not square ones. See here.
Example
I tried this
ActiveDocument.FormField("Issue status").Result = "Hello"

Open in new window


But I get 'object doesn't support this property or method'.

What am I doing wrong?

Thanks.
hindersalivaAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
Thanks. That has settled it. I was careless about the correct property to use. This works:
Activedocument.SelectContentControlsByTag("Issue Status")(1).Range.Text = "Hello"

Open in new window

0
 
EirmanChief Operations ManagerCommented:
Does manual updating work? (F9)
0
 
hindersalivaAuthor Commented:
Eirman, it's a placeholder that I need to update from some textboxes on a UserForm.
No, F9 would do nothing.

I now think these are Content Controls.
I'm thinking I should be able to update it like this. But it's not right, because the intellisense doesn't come up.
ActiveDocument.SelectContentControlsByTag("Status").Text = "Hello"

Open in new window

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
GrahamSkanRetiredCommented:
It might be a bookmark. If so, and if it's name is "IssueStatus" ("Issue Status" is illegal as a bookmark name) then try, after adding an 's' to FormField:
ActiveDocument.FormFields("IssueStatus").Result = "Hello"

Open in new window

If it's just a bookmark without being a FormField name then
ActiveDocument.Bookmarks("IssueStatus").Range.text= "Hello"

Open in new window

If that doesn't work either, post a non-confidential sample.
Note that you can use Find/GoTo to see the bookmark names in the document. Also Alt+F9 with toggle the display of fields in the Selection between result and code.
0
 
GrahamSkanRetiredCommented:
Oops. cross-posted.
SelectContentControlsByTag returns a collection, so try
ActiveDocument.SelectContentControlsByTag("Status")(1).Text = "Hello

Open in new window

"
0
 
GrahamSkanRetiredCommented:
Select the control and click Properties in the Developer tab to see the Tag and Title names
0
 
hindersalivaAuthor Commented:
Graham, I have attached a piece of the document. See the 'box' [Status]
Sample.docx
0
 
hindersalivaAuthor Commented:
Brilliant Graham. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.