Private Sub Document_Close()
Dim sColor As String
sColor = ComboBox1.Value
Me.CustomDocumentProperties("SelColor") = sColor
End Sub
Private Sub Document_Open()
Dim oProp As DocumentProperty
Dim iCtr As Integer
Dim vColor, vColors
Dim bPropExists As Boolean
vColors = Array("Green", "Red", "Blue")
For Each vColor In vColors
ComboBox1.AddItem vColor
Next
' Check if property exists
If Me.CustomDocumentProperties.Count > 0 Then
Set oProp = Me.CustomDocumentProperties.Item("SelColor")
If Not oProp Is Nothing Then bPropExists = True
End If
If Not bPropExists Then
' Add property to collection
Me.CustomDocumentProperties.Add "SelColor", False, _
msoPropertyTypeString, "Green"
' set default selection
ComboBox1.ListIndex = 0
Else
For iCtr = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(iCtr) = oProp.Value Then
ComboBox1.ListIndex = iCtr
Exit For
End If
Next
End If
End Sub