Excel Hack 66: Load a web page in Microsoft Excel

I’m sure you blinked a bit at the title of this Excel Hack. Why will I need Microsoft Excel to open a web page, when many web browsers (Chrome, Edge, Safari, etc.) exist?

Lol – I know. So let me share my use case.

I was on a project set up to review thousands of applications sent by candidates. Each candidate had filled a web form and submitted an application, and each application had a web link it could be accessed on. My work was to review each application, provide a score, and include comments justifying the score.

The manual approach to conducting this review would have involved 5 steps:

  1. Open the web browser, and navigate to the web page that includes the applicant’s entry
  2. Review the applicant’s entry in the web browser
  3. Switch windows to MS Excel, and locate the applicant’s ID on a table set up to collate review feedback
  4. Fill in the score and commentary for that applicant
  5. Intermittently switch back to the web browser to recall additional points for review, and switch back to MS Excel

You might wonder – why didn’t I extract all the filled applications in a tabular form into a database file, and open the file in Excel to do the review? Well, doing that will have resulted in an Excel document with several columns (over 50!). And reading applications in Excel is not fun – Excel cells are not optimized for reviewing long paragraphs of text.

So, to minimize the effort of navigating to each webpage, switching back and forth between Excel and the web browser (which, also introduces the risk of populating the wrong information against another ID), I built a review tool in MS Excel, to enable document review and feedback in the same window.

Here’s how I did it.

For confidentiality purposes, I redacted elements of the review tool and the actual application web page. I will demonstrate how this works using social media profiles of popular personalities.

Step 1: Create a table in Excel. Make this a formatted table (Ctrl + T) or make it a named range (Either will make it easy to reference in the code set up for the user form)

Step 2: Navigate to the Visual Basic Editor, and create a new User Form (Developer > Visual Basic Editor > Insert > UserForm).

Step 3: When a new User Form is generated, you will notice a toolbox window, right beside it. This toolbox contains the form controls you will bring into the user form, to program it.

To open web pages in MS Excel, you will need the Web Browser control. This control is not typically found on the tool box. You will need to activate it by right-clicking the tool box, selecting “Additional Controls…”, clicking Microsoft Web Browser in the list that comes up, and OK to confirm.

Right-click the Toolbox to access Additional Controls…
…scroll through the list till you see Microsoft Web Browser, click it, and click OK…
a new icon shows up on your Toolbox (when you hover your mouse on it – you see the name WebBrowser)

Step 4: Extend the Userform so it can accommodate a page-sized control, click the WebBrowser icon in the Toolbox and drag out the dimensions of a new Web Browser control on the Userform.

Step 5: Include additional user form controls on the user form – 3 text boxes for input of webpage name, number of likes, number of comments, 3 labels for each of the textboxes, and 2 command buttons – one to generate the webpage, and the other to submit the entry.

Add the first 3 controls – one label box, one text box, and one command button
Add 5 more controls – two label boxes, two text boxes, and one command button

Step 6: Double-click the Open web page command button to program it. What we want is for this button to, on click, open the web link entered into the web page name text box (named Textbox1), using the web browser control (named Web Browser1). This is a single line of code expressed below:

WebBrowser1.Navigate (Textbox1.Text)

Step 7: Create a new module, and add a Sub macro (Sub OpenReviewer) with one line of code (Userform1.Show), to get the user form to open in the worksheet. Assign this macro to a button on the worksheet to open up the user form and get it to work.

Create the macro to open the user form…
…and assign the macro to a button-shaped object on the worksheet

Click the button and try it out!

At this stage, we have created a web browser that works in Microsoft Excel. For the second part of the tutorial, that shows how to save the entries (number of likes and number of comments) filled on the user form into the Excel table, click Here.

One thought on “Excel Hack 66: Load a web page in Microsoft Excel

Leave a Reply

Your email address will not be published. Required fields are marked *