![remove content control microsoft word remove content control microsoft word](https://images.template.net/wp-content/uploads/2024/02/How-to-Enter-in-Microsoft-Excel-Within-a-Cell.jpg)
Sub IncludeTextFile(ByRef strFileName As String, strBMTarget As String) Paste the following procedure in the ThisDocument module (or use a new standard code module) of the Demo.dotm template project.Once resolved the appropriate file name and target bookmark name is then passed as arguments to a separate procedure (e.g., if "File A" is selected then "File A.docx" and the target bookmark name "FileTarget" is passed as arguments to the procedure named "IncludeTextFile." Notice a second "Select Case" is used to resolve which content control list entry the user selected.IncludeTextFile "File C.docx", "FileTarget" IncludeTextFile "File B.docx", "FileTarget" IncludeTextFile "File A.docx", "FileTarget" Construct the nested fields using the format shown below.Select and bookmark the content controls "Files." The bookmark serves as the reference for the Ref fields.The "Include Text" field used in this example includes the entire content of an external file. The first example uses the content control "Files," created in the review and a series of nested "If", "Ref" and and "IncludeText" fields placed in the template at the point inserted text should appear. The demonstration above should show that it can serve the dual purposes of the "Calculate on exit" or "Run a macro on exit" function available in legacy form fields.
![remove content control microsoft word remove content control microsoft word](https://www.codeproject.com/KB/sharepoint/744413/contentcontrolnaming.png)
Note: The Document_ContentControlOnExit event is a new document event introduced with content controls in Word 2007. 'The user exited some other content control that we don't care about. MsgBox "The user selected an offense, specifically: " & MsgBox "The user selected a file, specifically: " & Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, _
![remove content control microsoft word remove content control microsoft word](https://petri-media.s3.amazonaws.com/2016/04/Figure1.jpg)
OnExit Event:īefore getting to the examples I want to ensure that all visitors to this page are familiar with the Document_ContentControlOnExit event. Most of the examples could easily be adapted to include the insertion of data from other external sources (e.g., Excel or Access). Note: I have limited the discussion and examples in this page to Microsoft Word. It can also include text strings included in VBA procedures or even document variables.įriend and frequent tips project collaborator Graham Mayor provides a similar discussion and examples for inserting content based on a user selection or entry in legacy form fields: Insert content from a form fieldįor more on Content Controls see: Content Controls The source of the defined content can include text and graphics stored in other Word documents or text and graphics stored as Building Blocks in the document template or other external template (e.g., the Word Built-In Building Blocks.dotx). The purpose of this Microsoft Word Tips & Microsoft Word Help page is to review/introduce readers to the Document_ContentControlOnExit event and illustrate several methods that you can use to insert defined content (text or graphics) into your Word documents based on a selection or entry the document user makes in the document content controls