View Single Post
 
Old 04-19-2015, 09:47 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The code disappears almost certainly because you are saving the document as DOCX format which doesn't support macros, rather than DOCM format, which does.

Probably better still, save it as a macro enabled template (DOTM format) and create new documents from the template (File > New).

If you want the macro to ignore the default text in the list box, then leave in the two optional lines. The Debug.Print ContentControl.Range line is not required other than for testing.

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    If ContentControl.Tag = "TypeSelect" Then
        If Not ContentControl.Range = ContentControl.PlaceholderText Then 'Optional
            Select Case ContentControl.Range
                Case "Task"
                    ActiveDocument.ContentControls(2).Range = "Enter Steps"
                Case "Concept"
                    ActiveDocument.ContentControls(2).Range = "Enter Descriptive Content"
                Case Else
                    ActiveDocument.ContentControls(2).Range = "Enter Reference Data"
            End Select
        End If
    End If 'Optional with previous optional line
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote