473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HTML files to XLS

I have 1800 html files wich i extracted from a website with HTTrack. In this files are some infos that i need to put in a xls file.

A friend of mine tried to help me but ( he knows programming and stuff ) but told me it is to difficult.

So i start google-ing and this is what i came up with.
  1. I used a software for converting html files to xls.
  2. Searched this forum for a vb script and actualy worked very well. i have all the infos but one. In the html file there is a link that i must put allso in xls.
Once i converted html to xls the linked dissapeared so i am stuck now.

Searched a lot on google for other ways to do this but there had no luck.
May 30 '10 #1
7 1693
vb5prgrmr
305 Expert 100+
If you load the page via a webbrowser control you could use a for each loop to enumerate through the link in the page...
Expand|Select|Wrap|Line Numbers
  1. Dim Link As Object, Links As Object
  2.  
  3. WB.Navigate "file://c:\z\a\forums.html"
  4. Do While WB.ReadyState <> READYSTATE_COMPLETE
  5.   DoEvents
  6. Loop
  7. Set Links = WB.Document.getelementsbytagname("a")
  8. For Each Link In Links
  9.   Debug.Print Link.href
  10. Next
  11.  

Good Luck
May 30 '10 #2
I mangaed with help to put on every excell file the link. Eevery link is at A1 cell of every file like this : Mylink ( and it is hyperlinked with the link )

I have the script bellow, I just need to complet it with that A1 in my final xls. Can you help me guys ? i am a newbie

Thanks

Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim wb As Workbook
  3. Dim sht As Worksheet
  4. Dim r As Integer
  5. Set sht = ActiveSheet 'sheet for results
  6. r = 2 '1st row
  7. myDir = "C:\Documents and Settings\Adelina.ADELINA-467578F\Desktop\New Folder\"
  8. myfile = Dir(myDir & "*.xls")
  9. Do While Len(myfile) > 0
  10. Set wb = Workbooks.Open(myDir & myfile)
  11. fnd = False
  12. For Each ws In wb.Sheets
  13.     If ws.Name = "Sheet1" Then fnd = True: Exit For
  14. Next
  15. If fnd Then
  16. With wb.Sheets("Sheet1")
  17. sht.Cells(r, 1) = wb.Name
  18. sht.Cells(r, 2) = .Range("c76")
  19. sht.Cells(r, 3) = .Range("c77")
  20. sht.Cells(r, 4) = .Range("c78")
  21. sht.Cells(r, 5) = .Range("e78")
  22. sht.Cells(r, 6) = .Range("d78")
  23. sht.Cells(r, 7) = .Range("f78")
  24. sht.Cells(r, 8) = .Range("g77")
  25. sht.Cells(r, 9) = .Range("h77")
  26. sht.Cells(r, 10) = .Range("i77")
  27. sht.Cells(r, 11) = .Range("j77")
  28. sht.Cells(r, 12) = .Range("k77")
  29. sht.Cells(r, 13) = .Range("l77")
  30.  
  31. End With
  32. Else
  33. MsgBox "no cover note in " & wb.Name
  34. End If
  35. wb.Close
  36. myfile = Dir
  37. r = r + 1
  38. Loop
  39. End Sub
May 30 '10 #3
QVeen72
1,445 Expert 1GB
Hi,

At the end, just write :
sht.Cells(r, 14) = .Range("A1")
May 31 '10 #4
if so, i am getting the text from a1 and not the url behind the text :)
May 31 '10 #5
QVeen72
1,445 Expert 1GB
Hi,

Try this :

sht.Cells(r, 14) = Range("A1").Hyperlinks(1).Address

Regards
Veena
May 31 '10 #6
Hello. It finaly worked with your help. But now i have another problem. I have other xls files but every each file has no sheet1 but the name of the xls file.
can anyone help me rebuiding the script bellow ?

thanks

Eg of sheetname: dealers0a26



Sub test()
Dim wb As Workbook
Dim sht As Worksheet
Dim r As Integer
Set sht = ActiveSheet 'sheet for results
r = 2 '1st row
myDir = "C:\Documents and

Settings\Adelina.ADELINA-467578F\Desktop\xlsurile\"
myfile = Dir(myDir & "*.xls")
Do While Len(myfile) > 0
Set wb = Workbooks.Open(myDir & myfile)
fnd = False
For Each ws In wb.Sheets
If ws.Name = "Sheet1" Then fnd = True: Exit For
Next
If fnd Then
With wb.Sheets("Sheet1")
sht.Cells(r, 1) = wb.Name
sht.Cells(r, 2) = .Range("c76")
sht.Cells(r, 3) = .Range("c77")
sht.Cells(r, 4) = .Range("c78")
sht.Cells(r, 5) = .Range("d78")
sht.Cells(r, 6) = .Range("e78")
sht.Cells(r, 7) = .Range("a1")


End With
Else
MsgBox "no cover note in " & wb.Name
End If
wb.Close
myfile = Dir
r = r + 1
Loop
End Sub
Jun 7 '10 #7
QVeen72
1,445 Expert 1GB
Hi,

Just change it to :
Say,.. If my File is "C:\MyFolder\MyExclName.xls"
and if your sheet name is "MyExclName", then :

Expand|Select|Wrap|Line Numbers
  1. Dim NName As String
  2. NName = Dir(myFile, vbDirectory)
  3. NName = Left(NName, Len(NName) - 4)
  4. With wb.Sheets(NName)
  5.  
Regards
Veena
Jun 7 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Els | last post by:
***newbie question*** Hi, I am trying to make my server (Apache) parse .html files as .php. I found this line of code: ForceType application/x-httpd-php placed it in an .htaccess file and...
18
by: David Johnson | last post by:
I am looking for a way to combine the functionality of "include" and "here documents" so that an included html file containing $variables is expanded and handled (normally printed to stdout). It...
5
by: MK | last post by:
Dear friends, I have many HTML files and they all have some common HTML code which is basically bunch of tags which are in all the files. How can I put the common code in one file and then share...
1
by: ajk | last post by:
. Hi, All: I know how to insert files into a Word doc using C#. However, the program I've written to do this runs much too slowly. The "myObj".Application.Selection.InsertFile method executes...
4
by: ddd | last post by:
I am trying to build a diff tool that allows me to compare two HTML files. I am looking for resources on how to achive this. The main problem is that I do not want to simply highlight the line of...
4
by: Paul | last post by:
Hi still testing the idea of using html files for forms and then integrating this into a net app. I tried a small form with a button but noticed all I could do with the button is to right click and...
5
by: nick | last post by:
I need to create a simple asp.net application that use password protect some html pages. The html page provider doesn't know asp.net. And the host doesn't allow me to create user accounts. ...
2
by: nick | last post by:
I have an Asp.Net 2.0 application using form authentication. I want the html pages be protected by the authentication system too. The accessing of html files need to be authenticated in my local...
3
by: Keith | last post by:
I have an IIS 6.0 web server hosting an ASP.NET 2.0 web site. Help files for the site are pure html. Is there some way to serve these html pages using the same ASP.NET web site? If so, how do I...
2
by: D`Jinn Deegee | last post by:
I have 5 html files say file1.html file2.html : : file5.html Now I have another html file (main.html) where I want to use 1 html
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.