Using Dictionary.Exists in a UserForm property is giving Error 404 object required Using Dictionary.Exists in a UserForm property is giving Error 404 object required vba vba

Using Dictionary.Exists in a UserForm property is giving Error 404 object required


The Exists method is called like this:

Dictionary.Exists(Key)

So try

 Public Property Let ProjectOption(ByVal OptName As String, ByVal OptValue As String)    If Not DicOption.Exists(OptName) Then        DicOption.Add key:=OptName, Item:=OptValue    Else        DicOption(OptName) = OptValue    End IfEnd Property


A Scripting.Dictionary will implicitly call its Add method if you assign to a key that doesn't exist, so if the goal is to "add or replace" the value at the specified key, you could simply replace:

If Not DicOption(OptName).Exists Then    DicOption.Add key:=OptName, Item:=OptValueElse    DicOption(OptName) = OptValueEnd If

with:

DicOption.Item(OptName) = OptValue