Option
Explicit
Const
SOURCE_CC
As
String
=
"Gesellschaft"
Const
DEPENDENCY_CC
As
String
=
"Firma"
Const
DEPENDENCY_AN
As
String
=
"Adresse"
Const
DEPENDENCY_AP
As
String
=
"Ansprechpartner"
Const
DEPENDENCY_SW
As
String
=
"Software-Produkte"
Const
DEPENDENCY_BG
As
String
=
"Benutzergruppe"
Dim
dependentEntries
As
New
Collection
Dim
SWdependentEntries
As
New
Collection
Dim
ANdependentEntries
As
New
Collection
Dim
APdependentEntries
As
New
Collection
Private
Sub
initDependentEntries()
If
dependentEntries.Count = 0
Then
dependentEntries.Add Key:=
"Gesellschaft1"
, Item:=Array(
"Firma1"
,
"Firma2"
)
dependentEntries.Add Key:=
"Gesellschaft2"
, Item:=Array(
"Firma3"
,
"Firma4"
)
End
If
End
Sub
Private
Sub
Document_ContentControlOnExit(
ByVal
ContentControl
As
ContentControl, Cancel
As
Boolean
)
If
ContentControl.Tag = SOURCE_CC
Then
Dim
selectedEntry
As
String
: selectedEntry = ContentControl.Range.Text
Dim
cc
As
ContentControl:
Set
cc = getCCbyTitle(DEPENDENCY_CC)
If
Not
cc
Is
Nothing
Then
With
cc
.DropdownListEntries.Clear
initDependentEntries
Dim
entry
For
Each
entry
In
dependentEntries(selectedEntry)
.DropdownListEntries.Add entry
Next
.DropdownListEntries(1).
Select
End
With
End
If
End
If
End
Sub
Private
Function
getCCbyTitle(ccTitle
As
String
)
As
ContentControl
Set
getCCbyTitle =
Nothing
Dim
cc
As
ContentControl
For
Each
cc
In
ContentControls
If
cc.Title = ccTitle
Then
Set
getCCbyTitle = cc
Next
End
Function
Private
Sub
initAPDependentEntries()
If
APdependentEntries.Count = 0
Then
APdependentEntries.Add Key:=
"Firma1"
, Item:=Array(
"Ansprechpartner1"
,
"Ansprechpartner2"
)
APdependentEntries.Add Key:=
"Firma2"
, Item:=Array(
"Ansprechpartner1"
,
"Ansprechpartner2"
)
End
If
End
Sub
Private
Sub
initSWDependentEntries()
If
SWdependentEntries.Count = 0
Then
SWdependentEntries.Add Key:=
"Software1"
, Item:=Array(
"Benutzergruppe1"
,
"Benutzergruppe2"
,
"Benutzergruppe3"
)
SWdependentEntries.Add Key:=
"Software2"
, Item:=Array(
"Benutzergruppe1"
,
"Benutzergruppe2"
,
"Benutzergruppe3"
)
End
If
End
Sub
Private
Sub
SWDocument_ContentControlOnExit(
ByVal
ContentControl
As
ContentControl, Cancel
As
Boolean
)
If
ContentControl.Tag = SOURCE_SW
Then
Dim
selectedEntry
As
String
: selectedEntry = ContentControl.Range.Text
Dim
sw
As
ContentControl:
Set
sw = getSWbyTitle(DEPENDENCY_SW)
If
Not
sw
Is
Nothing
Then
With
sw
.DropdownListEntries.Clear
initSWDependentEntries
Dim
entry
For
Each
entry
In
SWdependentEntries(selectedEntry)
.DropdownListEntries.Add entry
Next
.DropdownListEntries(1).
Select
End
With
End
If
End
If
End
Sub
Private
Function
getSWbyTitle(swTitle
As
String
)
As
ContentControl
Set
getSWbyTitle =
Nothing
Dim
sw
As
ContentControl
For
Each
sw
In
ContentControls
If
sw.Title = swTitle
Then
Set
getSWbyTitle = sw
Next
End
Function