Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2015, 10:30 AM
ciresuark ciresuark is offline VBA for content controls Windows 7 32bit VBA for content controls Office 2010 32bit
Novice
VBA for content controls
 
Join Date: Oct 2014
Posts: 7
ciresuark is on a distinguished road
Default 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
Few questions.
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.
Reply With Quote
  #2  
Old 03-10-2015, 03:14 PM
gmaxey gmaxey is offline VBA for content controls Windows 7 32bit VBA for content controls Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,438
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
There are considerably better ways to defined conditional text based on a list selection that IF fields. See: http://gregmaxey.com/word_tip_pages/...wn%20list.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA for content controls 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
VBA for content controls Content Controls Sammie0Sue Word 6 11-06-2013 10:56 PM
VBA for content controls Grouping Content Controls cksm4 Word VBA 2 03-01-2011 12:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft