VBA Code


Selection.TypeText Text:="a1" 
Selection.Range.InsertAutoText
ActiveDocument.AttachedTemplate.AutoTextEntries("autotext_name").Insert Where:=Selection.Range, RichText:=True


Content Controls


Word.wdContentControlType. 
objDocument.ContentControls
objRange.ContentControls

Public Sub ContentControls_ListAll() 
Dim objcontentcontrols As Word.ContentControls
Dim objcontentcontrol As Word.ContentControl
Dim icontrols As Integer

    Set objcontentcontrols = ActiveDocument.Range.ContentControls
    
    For icontrols = 1 To objcontentcontrols.Count
        Set objcontentcontrol = objcontentcontrols.Item(icontrols)
                
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlRichText) Then
            Debug.Print icontrols & " - wdContentControlRichText - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlText) Then
            Debug.Print icontrols & " - wdContentControlText - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlPicture) Then
            Debug.Print icontrols & " - wdContentControlPicture - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlComboBox) Then
            Debug.Print icontrols & " - wdContentControlComboBox - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlDropdownList) Then
            Debug.Print icontrols & " - wdContentControlDropdownList - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlDate) Then
            Debug.Print icontrols & " - wdContentControlDate - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlBuildingBlockGallery) Then
            Debug.Print icontrols & " - wdContentControlBuildingBlockGallery - " & objcontentcontrol.Tag
        End If
        If (objcontentcontrol.Type = WdContentControlType.wdContentControlGroup) Then
            Debug.Print icontrols & " - wdContentControlGroup - " & objcontentcontrol.Tag
        End If
    Next icontrols
    
End Sub


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev