Fumer Tue
01-28-2011, 01:17 PM
In Word 2007 I am using the following code to allow a selection made in dropdown box 1 ("dropdown1")to populate a second dropdown box ("Result").
What I'd like to do is have the one selection populate six dropdown boxes - with the same stuff each time - there will be more content once I've got it working by the way.
I'm a total novice, but keen to learn!
CODE:
Option Explicit
Sub FirstFieldExit()
Dim Understanding(4) As String
Dim Using(3) As String
Dim Level2(3) As String
Dim i As Integer
Dim var
Understanding(0) = "1.2 Health & safety (worksheet)"
Understanding(1) = "2.1 Monitors (worksheet)"
Understanding(2) = "2.3 Project folders (worksheet)"
Understanding(3) = "Recap Ex (exercise)"
Understanding(4) = "3.1a Project Window 1 (worksheet)"
Using(0) = "Us1"
Using(1) = "Us2"
Using(2) = "Us3"
Using(3) = "Us4"
Level2(0) = "21"
Level2(1) = "22"
Level2(2) = "23"
Level2(3) = "24"
' use the value of the dropdown to case select condition
Select Case ActiveDocument.FormFields("Dropdown1").DropDown.Value
Case 1
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Understanding(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 2
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Using(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 3
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Level2(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
End Select
End Sub
What I'd like to do is have the one selection populate six dropdown boxes - with the same stuff each time - there will be more content once I've got it working by the way.
I'm a total novice, but keen to learn!
CODE:
Option Explicit
Sub FirstFieldExit()
Dim Understanding(4) As String
Dim Using(3) As String
Dim Level2(3) As String
Dim i As Integer
Dim var
Understanding(0) = "1.2 Health & safety (worksheet)"
Understanding(1) = "2.1 Monitors (worksheet)"
Understanding(2) = "2.3 Project folders (worksheet)"
Understanding(3) = "Recap Ex (exercise)"
Understanding(4) = "3.1a Project Window 1 (worksheet)"
Using(0) = "Us1"
Using(1) = "Us2"
Using(2) = "Us3"
Using(3) = "Us4"
Level2(0) = "21"
Level2(1) = "22"
Level2(2) = "23"
Level2(3) = "24"
' use the value of the dropdown to case select condition
Select Case ActiveDocument.FormFields("Dropdown1").DropDown.Value
Case 1
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Understanding(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 2
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Using(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 3
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Level2(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
End Select
End Sub