Gruppe
Extern
Problem
Wie kann ich eine Excel-Tabelle möglichst schnell in das HTML-Format konvertieren?
StandardModule: basMain
Sub XL2HTML()
Dim iRow As Integer, iCol As Integer
Dim sFile As String
sFile = Range("K1").Value
Close
On Error GoTo ERRORHANDLER
Open sFile For Output As #1
On Error GoTo 0
Print #1, "<html>"
Print #1, "<header>"
Print #1, "<style type=""text/css"">"
Print #1, "td {"
Print #1, " font-size:9pt;"
Print #1, " font-family:tahoma,verdana;"
Print #1, " background-color:#ffffe0"
Print #1, " }"
Print #1, "</style>"
Print #1, "</header>"
Print #1, "<body bgcolor=#d0d0d0><center>"
Print #1, "<table bgcolor=#003000 border=3" & _
"cellpadding=3 cellspacing=3>"
For iCol = 1 To 8
Print #1, " <td><b>" & Cells(1, iCol).Text & "</b></td>"
Next iCol
For iRow = 2 To 7
Print #1, " <tr>"
For iCol = 1 To 8
If Not IsEmpty(Cells(iRow, iCol)) Then
If iCol < 3 Then
Print #1, " <td>" & Cells(iRow, iCol).Text & "</td>"
Else
Print #1, " <td align=right>" & _
Cells(iRow, iCol).Text & "</td>"
End If
Else
Print #1, " <td> </td>"
End If
Next iCol
Print #1, " </tr>"
Next iRow
Print #1, "</table></center>"
Print #1, "</body>"
Print #1, "</html>"
MsgBox "Datei wurde angelegt:" & vbLf & sFile
End
ERRORHANDLER:
MsgBox "Bitte den Verzeichnisnamen überprüfen!"
End Sub