Unexpected results from typename

前端 未结 1 433
攒了一身酷
攒了一身酷 2020-12-07 04:51

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         


        
相关标签:
1条回答
  • 2020-12-07 05:23
    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
    
    0 讨论(0)
提交回复
热议问题