Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Opening an HTML Page in a Macro.

Opening an HTML Page in a Macro

by Allen Wyatt
(last updated May 6, 2016)


Excel is a "Web aware" program, meaning that it knows how to handle hyperlinks. You can add a hyperlink in a document, click on that link, and Excel opens your Web browser and displays the contents of that link in the browser. (You can also create a hyperlink to other Office documents, including Excel workbooks.) You can even create hyperlinks to different objects on your worksheet, such as a command button in a form.

What if you want to start the browser and open an HTML file from within a VBA macro, however? There are a couple of ways that you can do this. The first is to simply open a new Internet Explorer object within your code. A macro to do this would appear as follows:

Sub DoBrowse1()
    Dim ie As Object
    Set ie = CreateObject("Internetexplorer.Application")
    ie.Visible = True
    ie.Navigate "c:\temp\MyHTMLfile.htm"
End Sub

This macro will open the file c:\temp\MyHTMLfile.htm in a new Internet Explorer window. If you want to instead open a Web page from over the Internet, you can do so simply by changing where you want to navigate. (Replace the file path with a URL.)

Another way to accomplish the same task is to rely on Excel to figure out what your default browser is and open the HTML resource. The following macro does the trick:

Sub DoBrowse2()
    ActiveWorkbook.FollowHyperlink _
      Address:="c:\temp\MyHTMLfile.htm", _
End Sub

Again, the browser opens a new window and displays the specified file. You can change the Address parameter to any URL that you desire.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (154) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Opening an HTML Page in a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Deleting MRU Entries

By default Word dutifully keeps track of the different files you've worked on in the past. If you want to delete an entry ...

Discover More

Adjusting Your View of 3-D Graphs

Do you use Excel's charting capabilities to display three-dimensional views of your data? The program provides a way that ...

Discover More

Sizing Text Boxes and Cells the Same

Adding a text box to a worksheet is easy. Making sure that text box is the exact size of a cell in the worksheet may not ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Setting Web Fonts

Is your worksheet information destined for a Web page? Here's how you can specify the fonts that should be used when ...

Discover More

Automatic Text in an E-mail

When creating an e-mail address hyperlink using the Insert Hyperlink dialog box, Excel allows you to enter a subject for ...

Discover More

Sending Single Worksheets via E-mail

Got a single worksheet that you want to e-mail to someone, but don't want them to see the rest of the worksheets in the ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three more than 8?

2016-09-07 10:43:20

Zoltan Breller

Works like a charm
Thank you.

2016-05-07 03:29:56

Wellsley Over

Hi Allen, I want to thank you if I haven't already for for all the great tips I get. Being a beginner to vba the tips are money in the bank.

2014-10-14 09:22:06

Bigger Don


It looks like it is possible but I wouldn't necessarily trust the re-usability, stability or portability.

If you really want to do this here are the steps.
1. Do a Google search
2. Copy the URL.
3. Replace "c:tempMyHTMLfile.htm" with the URL you copied.

Of course you would probably want to make the last element of the URL, the search term, into a variable to plug into the search. That way you could re-use the code for different situations, perhaps even called by a UDF in the UI.

This brings up an issue. Let's say your user types in a one word term then you are OK. If they type a multi-word query term, or you've constructed one in your code, then you'll need to do some translating: replace spaces with plus ("+") signs, replace quotes with "%22", and I suspect there are other situations.

Something else I mentioned was portability. DoBrowse1 uses ActiveX. Creating an ActiveX component for Firefox and Chrome did not work straightaway for me. I do not know if it is possible.

Here are the three URLs for Chrome, Firefox, and IE.
* Chrome:
* Firefox:
* IE:

As I see it, the URL includes browser settings, and the way the settings show up in the URL differs. You would need to test for the effect of different browser settings. You would need to test any browsers you do support, of course, and different versions of of each because I would not trust any of them to be fully consistent from one release to the next.

...or you can force everyone to use on release of I.E. :)

2014-10-13 15:09:57


First, THANK YOU for the instructions, they work wonderfully. Now, how might I get it to search? Have excel open to google and then search 'autozone'.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.