January 28, 2020

Create UserForm with Web Browser Functionality

How to create a user-form with basic web browser functionality using VBA.
Here’s the complete VBA code:
Option Explicit

Private Sub cmdBack_Click()
On Error Resume Next
WebBrowser1.GoBack
Err.Clear
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub cmdForward_Click()
On Error Resume Next
WebBrowser1.GoForward
Err.Clear
End Sub

Private Sub cmdNavigate_Click()
WebBrowser1.Navigate “http://www.” & TextBox1.Text
End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()
With Application
.WindowState = xlMaximized
Zoom = Int(.Width / Me.Width * 100)
Width = .Width
Height = .Height
End With
WebBrowser1.Navigate “https://www.youtube.com”
End Sub

2 thoughts on “Create UserForm with Web Browser Functionality

  1. Dear Dinesh,

    Thank you for posting valuable vidoes on Excel.

    Do you know how we can view a pdf file in Webbrowser control and copy all it’s contents as text only, and paste it in Excel?

    The user has only Adobe Reader.

    Look forward to hearing from you.

    Regards,
    Donald

  2. Of course… does not function.

    Start with clarification on brower : ie ? FoxPro ? Chrome ?….
    Also… version windows ? 32-64 ? Version Office ?

Comments are closed.