Solved

Open an html page in an Excel worksheet with VBA

Posted on 2010-08-27
8
491 Views
Last Modified: 2012-05-10
How can I open an HTML page in a specific worksheet with Excel VBA? I currently do an import which works ok, but I wanted to keep the original page.
0
Comment
Question by:bellboy2k
8 Comments
 
LVL 10

Expert Comment

by:MaduKp
ID: 33540200
0
 

Author Comment

by:bellboy2k
ID: 33540215
Thanks, but I found that same article. I need the HTML file to open in a Worksheet.
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 33540350
In a new workbook, it's fairly easy.

Dim mb As Workbook
Set mb = Workbooks.Open("http://www.printware.co.uk/Products/Result-Groups.html?searchtext=A0DK152")

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 17

Expert Comment

by:calacuccia
ID: 33540368
Dim mb As Workbook
Set mb = Workbooks.Open("http://www.printware.co.uk/Products/Result-Groups.html?searchtext=A0DK152")
'The line below moves the workbook to a new sheet before Sheet1 in ThisWorkbook, which is the workbook from which you call the VBA macro
mb.Worksheets(1).Move ThisWorkbook.Worksheets("Sheet1")
0
 

Author Comment

by:bellboy2k
ID: 33540408
That worked, but how do I get it to load ina a specific Worksheet, I have a report that runs every morning and I have an HTML page that I need to load into a specific Worksheet called EDLC from a local folder, let's say c:\test\edlc.mht.
0
 
LVL 17

Accepted Solution

by:
calacuccia earned 250 total points
ID: 33540455
With this type of macro it should open the other book, move the webpage into that book, delete the old EDLC page and rename the new page to EDLC.

Dim mb As Workbook
Dim otherB as workbook
Dim newS as worksheet
Set mb = Workbooks.Open("http://www.printware.co.uk/Products/Result-Groups.html?searchtext=A0DK152")
Set otherB = Workbooks.Open("c:\test\edlc.mht.xls")
'The line below moves the workbook to a new sheet before Sheet1 in ThisWorkbook, which is the workbook from which you call the VBA macro
mb.Worksheets(1).Move otherB.Worksheets("EDLC")
Set newS = ActiveSheet
otherB.Worksheets("EDLC").Delete
newS.Name = "EDLC"
0
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33540503
Would this work?
Range("A1").LoadText("c:\test\edlc.mht")

Open in new window

0
 

Author Closing Comment

by:bellboy2k
ID: 33540509
Thanks calacuccia for the solution and the quick response!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question