E
EMonk
This one seems to come up a lot, and most of the answers to it are
based on the Microsoft KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;161397
For those of us locked into using older versions of Access this has
caused endless amounts of frustration.
After butting my head against this one off and on for a few months
(since I REALLY wanted to fix it), I found a workaround that seems to
do what I need it to: embed the webbrowser in a MSForms Frame.
Here's an excerpt from one of my modules:
---[startcode]---
Private WithEvents BrowserObj As SHDocVw.WebBrowser
' convenience function...
Private Function Frame() As MSForms.Frame
Set Frame = Frame1.Object
End Function
' return the browser object, creating if necessary
Public Function Browser() As SHDocVw.WebBrowser
On Error Resume Next
' locate web browser control...
Dim ctrl As MSForms.Control, res As SHDocVw.WebBrowser
For Each ctrl In Frame.Controls
On Error Resume Next
Set res = Nothing
Set res = ctrl
On Error GoTo 0
If Not res Is Nothing Then Exit For
Next
' check that we found a web browser
If res Is Nothing Then
' not found... create a new one
On Error Resume Next
Set ctrl = Frame.Controls.Add("Shell.Explorer.2", "wb", false)
If ctrl Is Nothing Then Exit Function
ctrl.Left = 0
ctrl.Top = 0
Set res = ctrl
On Error GoTo 0
End If
Set BrowserObj = res
Set Browser = res
End Function
' size the WebBrowser object to fit inside the Frame
Private Sub ResizeBrowser()
On Error Resume Next
With Frame.Controls("wb")
.Width = Frame.InsideWidth
.Height = Frame.InsideHeight
End With
End Sub
---[endcode]---
With the appropriate code inside the Form_Resize to size the Frame and
call ResizeBrowser, this functions fine. Events can be hooked into
the BrowserObj and fire without problems (so far).
Comments?
based on the Microsoft KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;161397
For those of us locked into using older versions of Access this has
caused endless amounts of frustration.
After butting my head against this one off and on for a few months
(since I REALLY wanted to fix it), I found a workaround that seems to
do what I need it to: embed the webbrowser in a MSForms Frame.
Here's an excerpt from one of my modules:
---[startcode]---
Private WithEvents BrowserObj As SHDocVw.WebBrowser
' convenience function...
Private Function Frame() As MSForms.Frame
Set Frame = Frame1.Object
End Function
' return the browser object, creating if necessary
Public Function Browser() As SHDocVw.WebBrowser
On Error Resume Next
' locate web browser control...
Dim ctrl As MSForms.Control, res As SHDocVw.WebBrowser
For Each ctrl In Frame.Controls
On Error Resume Next
Set res = Nothing
Set res = ctrl
On Error GoTo 0
If Not res Is Nothing Then Exit For
Next
' check that we found a web browser
If res Is Nothing Then
' not found... create a new one
On Error Resume Next
Set ctrl = Frame.Controls.Add("Shell.Explorer.2", "wb", false)
If ctrl Is Nothing Then Exit Function
ctrl.Left = 0
ctrl.Top = 0
Set res = ctrl
On Error GoTo 0
End If
Set BrowserObj = res
Set Browser = res
End Function
' size the WebBrowser object to fit inside the Frame
Private Sub ResizeBrowser()
On Error Resume Next
With Frame.Controls("wb")
.Width = Frame.InsideWidth
.Height = Frame.InsideHeight
End With
End Sub
---[endcode]---
With the appropriate code inside the Form_Resize to size the Frame and
call ResizeBrowser, this functions fine. Events can be hooked into
the BrowserObj and fire without problems (so far).
Comments?