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. ...


Managing Comments

If you frequently add comments to cells in a worksheet, Excel provides a variety of tools you can use to manage those ...

Discover More

Matching Formatting when Concatenating

Convert a numeric value to text and you may be surprised by how Excel displays the value. Here's a run-down on exactly ...

Discover More

Accurate Font Sizes

Need to use some bizarre font size in your worksheet? Not a problem, provided it is a full or half point size.

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Drop-Down List of Hyperlinks

Creating a drop-down list with Excel's data validation feature can be a nice touch for a worksheet. What if you want the ...

Discover More

Hyperlinks No Longer Work in a Workbook

Hyperlinks can be a great timesaver and very convenient. Unless, of course, if they don't work as you expect. This tip ...

Discover More

Extracting Hyperlink Information

In Excel, a hyperlink consists of two parts: the text displayed for the link and the target of the link. You can use a ...

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 1 + 5?

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.