In this example I am opening the worksheet Sheet2 from workbook test2.xls.
Sub q()
'code written on 24/09/2008 by Pavandeep Puddupakkam
FileNum = FreeFile ' next file number
Open "C:\Hotfrog\test1.html" For Output As #FileNum ' creates the file if it doesn't exist
Workbooks("test2.xls").Activate
Sheets("Sheet2").Activate
If Cells(1, 1) <> "" Then
Title = Cells(2, 2)
URL = Cells(1, 2)
Print #FileNum, Cells(1, 2)
Print #FileNum, "<title>"; Title; "</title>"
Print #FileNum, "</head>"
Else
Print #FileNum, "<body>"
Print #FileNum, "<table cellpadding="; """1"""; " cellspacing="; """1"""; " border="; """1"""; ">"
Print #FileNum, "<thead>"
Print #FileNum, "<tr><td rowspan="; """1"""; " colspan="; """3"""; ">"; Title; "</td></tr>"
Print #FileNum, "</thead><tbody>"
End If
Close #FileNum ' close the file
End Sub
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5