I am getting some unexpected results from typename and am stumped. Hopefully some can point me in the right direction.
Private Sub T()
Dim d As Word.Doc
c.Add (d)
is not the same as
c.Add d
In the first, by wrapping d
in parentheses you're causing it to be evaluated as an expression and the result of that expression (in this case a String) gets added to the collection. In the second, the d
object itself is added.
Try comparing directly in the Immediate window:
? TypeName(ActiveDocument) '>> Document
and
? TypeName( (ActiveDocument) ) '>> String