Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Download:

Datei 1: Checkliste01.docm

Word template for showing and hiding areas.

 

The following Word template does the following.

When you click on the checkbox ❎Does not hit the following table area, the rows are hidden.

When you click on the checkbox field ❎  Hits to, the hidden table area appears again.

 

In the background runs a vba macro (code is attached below) that hides an area with Selection.Collapse

 

Shown: Word Collapse

 

Show in Word

Displayed area

 

Hide / Hidden Rows of a Table

 

Option Explicit On

 

Private Sub Document_ContentControlOnEnter(ByVal contentControl As contentControl)

    '---------< Document_ContentControlOnEnter >--------

    If contentControl.Type = wdContentControlCheckBox Then

        '----< IsCheckbox >----

        '< init >

        Dim activeCheckbox As contentControl

        Set activeCheckbox = contentControl

       

        Dim sCellText

        sCellText = activeCheckbox.Range.Cells(1).Range.Text

        '</ init >

 

 

 

        '< Tabelle markieren >

        Dim activeTable As Table

        Set activeTable = activeCheckbox.Range.Tables(1)

       

        Dim tableContentRange As Range

        Set tableContentRange = activeTable.Rows(2).Range

        tableContentRange.End = activeTable.Range.End

        tableContentRange.Select

        '</ Tabelle markieren >

 

        If sCellText Like "*nicht*" Then

            '< ausblenden >

            Selection.Expand Unit:=wdParagraph

            Selection.Range.Font.Hidden = True

            Selection.Collapse wdCollapseEnd

            '</ ausblenden >

 

            activeTable.Rows(1).Cells(4).Range.ContentControls(1).Checked = False

        ElseIf sCellText Like "*Trifft zu*" Then

            '< einblenden >

            Selection.Expand Unit:=wdParagraph

            Selection.Range.Font.Hidden = False

            Selection.Collapse wdCollapseEnd

            '</ einblenden >

 

            activeTable.Rows(1).Cells(3).Range.ContentControls(1).Checked = False

        End If

        '----< IsCheckbox >----

    End If

    '---------</ Document_ContentControlOnEnter >--------

End Sub

 

 

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de