How do I make the cursor jump to a particular content control?

A

Ailish

Please can anybody show me how to use vba to make the cursor select a
specific content control in a document that has many CCs?
 
J

Jay Freedman

Please can anybody show me how to use vba to make the cursor select a
specific content control in a document that has many CCs?

When you create the document (or, better, its template), open each
content control's Properties dialog and enter a unique tag value.
Unlike the title, which appears when the CC is selected, the tags
aren't visible to users but a macro can read them.

The macro can do something like this:

Sub x()
Dim cc As ContentControl

For Each cc In ActiveDocument.ContentControls
If cc.Tag = "t3" Then
cc.Range.Select
Exit For
End If
Next
End Sub

This will select the CC whose tag value is t3. Of course, you can use
any strings you like for the tags.
 
A

Ailish

Thank you Jay. That's exactly what I needed.
Sorry for the delay in returning to check for an answer - it's been a busy
week.

Ailish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top