Excel vba userform containing WebBrowsers on initialisation closes excel without error message, and recovers the file. Why?

Viewed 306

This works on my normal laptop 16Gb ram and excel office 365, but when I am using my tablet pc with 4Gb ram and excel office 365. When I initialise a particular userform that contains two webbrowsers, it causes excel to crash, I do not receive any error messages, it looks like its thinking about it and then excel just closes and re-opens with a recovered version. All my other code works fine.

This works ok on my laptop with 16Gb ram the version of windows and excel are the same, the only difference is the 4Gb. I was expecting it to only take longer with the difference in ram, is it a memory issue?

When I blanked out the following lines the userform loads fine (just obviously without the webpages being navigated to)

Me.WebBrowser1.Silent = True

Me.WebBrowser1.Navigate "https://www.nutracheck.co.uk/CaloriesIn/"

Me.WebBrowser2.Navigate "about:blank"

Me.WebBrowser2.Document.Write "<img style=""width:100%;""

src=""https://media.giphy.com/media/MIY4jpusckRmU/giphy.gif"">"

WebBrowser2.Document.Body.Style.Border = "none"

WebBrowser2.Document.Body.Scroll = "no"*

Private Sub UserForm_Initialize()

With Application
' here I have code to format and position labels and command buttons on 
'userform according to screen size
End With


'next line suppresses script errors in the web browser window
Me.WebBrowser1.Silent = True

Me.WebBrowser1.Navigate "https://www.nutracheck.co.uk/CaloriesIn/"

Me.WebBrowser2.Navigate "about:blank"
Me.WebBrowser2.Document.Write "<img style=""width:100%;""
src=""https://media.giphy.com/media/MIY4jpusckRmU/giphy.gif"">"

With Application
WebBrowser1.Top = .Top + 40
WebBrowser1.Left = AddARecipe.Left + (AddARecipe.Width * 0.48)
WebBrowser1.Height = .Height - 40
WebBrowser1.Width = AddARecipe.Width * 0.5

End With

With Application
WebBrowser2.Top = .Top + 60
WebBrowser2.Left = 0 '10
WebBrowser2.Height = (AddARecipe.Width * 0.243) 
WebBrowser2.Width = (AddARecipe.Width * 0.45) 
WebBrowser2.Visible = False
WebBrowser2.Document.Body.Style.Border = "none"
WebBrowser2.Document.Body.Scroll = "no"

End With

End Sub

When the code is run unaltered, and I step through the code no error messages come up, its just at "end sub" excel closes.

0 Answers
Related