#1
|
|||
|
|||
VBA for content controls
I am using the following code to update fields in a document. I am using an IF formula based upon a combo box.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Selection.WholeStory Selection.Fields.Update End Sub 1. Is it possible to set up VBA to only function on one content control in a letter? 2. With the code above the whole document is selected, and remains highlighted after the fields update. Is there code to remove the highlighting the document, like a click of the mouse? Thank you for your assistance. |
#2
|
|||
|
|||
You don't have to select anything.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Select Case ContentControl.Title 'or .Tag Case "Title of CC you want this code to fully execute" ActiveDocument.Fields.Update End Select End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to set Content controls as non printing | Sammie0Sue | Word VBA | 21 | 01-12-2021 04:44 PM |
Calculate Age From Content Controls | kintap | Word VBA | 10 | 07-02-2014 09:25 AM |
Content Controls in Headers | ejungk99 | Word | 2 | 06-16-2014 04:02 PM |
Content Controls | Sammie0Sue | Word | 6 | 11-06-2013 10:56 PM |
Grouping Content Controls | cksm4 | Word VBA | 2 | 03-01-2011 12:46 PM |