I think you are looking for TypeName, not TypeOf.
If TypeName(foobar) = "CommandButton" Then DoSomething End If
Edit: what do you mean by dynamic objects? You mean objects created using CreateObject ("") because this should work.
Edit:
Private Sub Command1_Click() Dim oObject As Object Set oObject = CreateObject("Scripting.FileSystemObject") Debug.Print "Object Type: " & TypeName(oObject) End Sub
Outputs
Object Type: FileSystemObject
Kris Erickson
source share