Andrew, sweet!
That solution should be booked as a function! Here is my stab:
Code:
Sub Test()
Dim oDic As Object
Set oDic = CreateObject("Scripting.Dictionary")
oDic.Add "1", "Apples"
oDic.Add "2", "Blue Berries"
oDic.Add "3", "Cherries"
'Where the "Exists" method tells us if a key is present in a dictionary ...
MsgBox oDic.Exists("1")
'... the following function tells us if a value exists
MsgBox fcnDicValueExists(oDic, "Cherries")
lbl_Exit:
Set oDic = Nothing
Exit Sub
End Sub
Function fcnDicValueExists(oDicPassed, varValue) As Boolean
'Created from suggestions offered by Andrew Lockton in the Word VBA Forum.
Dim oArrList As Object, varMembers, varString
'Convert dictionary list members to an ArrayList
Set oArrList = CreateObject("System.Collections.Arraylist")
oArrList.Add oDicPassed.Items
'Convert ArrayList to array
varMembers = oArrList.ToArray
'Join array element members to a delimited string
varString = Join(varMembers(0), "|") & "|"
'Test if value found in string
fcnDicValueExists = InStr(varString, varValue & "|") > 0
lbl_Exit:
Exit Function
End Function