Solved

Open an html page in an Excel worksheet with VBA

Posted on 2010-08-27
8
462 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now