根据对象库里的对象逻辑名获取对象的class

Function GetObjectClass(ByVal LogicalName)

 GetObjectClass = ""

 Dim arrTypes

 arrTypes = Array("Browser", "Window", "Dialog", "JavaWindow")

 On Error Resume Next

 For each sType in arrTypes

  Err.Clear

  Set TempObj = Eval(sType & "(" & LogicalName & ")")

  If Err.Number = 0 then

   'Match found

   GetObjectClass = sType

   On Error Goto 0

   Exit Function

  End if

 Next

 On Error Goto 0

End Function

 

posted @ 2012-07-09 14:35  dushuai  阅读(236)  评论(0编辑  收藏  举报