使用Win64,VBA7 32位上一个简单的程序组合来处理Internet Explorer实例(IE实例),我发现:
一个。该函数正确地将IE实例类型标识为IWebBrowser2;
湾sub错误地将IE实例类型标识为String。
有人会轻轻地分享原因吗?
提前致谢。
Sub SimpleTest()
Dim iemIE As InternetExplorer
Dim oDummy As Object
Set ieIE = New InternetExplorer
Set oDummy = mahFunction(ieIE)
mahSub (ieIE)
ieIE.Quit
End Sub
Function mahFunction(InternetExplorerThatHasMahObject As Variant) As Object
Dim sFunctionTypeName As String
Dim bFunctionTestIE As Boolean, bFunctionTestIEM As Boolean
sFunctionTypeName = TypeName(InternetExplorerThatHasMahObject) 'returns "IWebBrowser2"
bFunctionTestIE = TypeOf InternetExplorerThatHasMahObject Is InternetExplorer 'returns True
bFunctionTestIEM = TypeOf InternetExplorerThatHasMahObject Is InternetExplorerMedium 'returns True
MsgBox sFunctionTypeName & ", " & bFunctionTestIE & ", " & bFunctionTestIEM
Set mahFunction = Nothing
End Function
Sub mahSub(InternetExplorerToWaitFor As Variant)
Dim sSubTypeName As String
Dim bSubTestIE As Boolean, bSubTestIEM As Boolean
sSubTypeName = TypeName(InternetExplorerToWaitFor) 'returns "String"
bSubTestIE = TypeOf InternetExplorerToWaitFor Is InternetExplorer 'returns False
bSubTestIEM = TypeOf InternetExplorerToWaitFor Is InternetExplorerMedium 'returns False
MsgBox sSubTypeName & ", " & bSubTestIE & ", " & bSubTestIEM
End Sub