Try dynamically creating the WebBrowser control (remove the reference to Microsoft Internet Controls first) so you can adjust your code according to the OS:
Tested only on XP.Code:'In a Form Option Explicit Private WithEvents WebBrowser As VBControlExtender Private IsWinXP As Boolean, IsWin8 As Boolean Private Sub Form_Activate() 'Use the object property of VBControlExtender to access other methods of the WebBrowser WebBrowser.object.Navigate "http://www.vbforums.com/" End Sub Private Sub Form_Load() 'Add OS version test here (or better yet, test IE version) IsWinXP = True 'Not sure if ProgId's same for Win8 Set WebBrowser = Controls.Add("Shell.Explorer.2", "WebBrowser1") WebBrowser.Visible = True End Sub Private Sub Form_Resize() If WindowState <> vbMinimized Then WebBrowser.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight End Sub Private Sub Form_Unload(Cancel As Integer) Set WebBrowser = Nothing Controls.Remove "WebBrowser1" End Sub Private Sub WebBrowser_ObjectEvent(Info As EventInfo) With Info Select Case .Name Case "StatusTextChange" With .EventParameters Select Case True Case IsWinXP: Caption = .Item("Text") Case IsWin8: Caption = .Item("Text") End Select End With Case "FileDownload" With .EventParameters Select Case True Case IsWinXP: WebBrowser2_FileDownload_XP .Item("Cancel") Case IsWin8: WebBrowser2_FileDownload_8 .Item("ActiveDocument"), .Item("Cancel") End Select End With Case "Other Events Here" End Select End With End Sub Private Sub WebBrowser2_FileDownload_XP(Cancel As Boolean) End Sub Private Sub WebBrowser2_FileDownload_8(ByVal ActiveDocument As Boolean, Cancel As Boolean) End Sub
References:
How To Dynamically Add Controls to a Form with Visual Basic 6.0
How to load a control at runtime.
VBControlExtender Object




Reply With Quote
