Gruppe
Extern
Problem
Von allen Arbeitsblättern der Arbeitsmappe sollen HTML-Dateien angelegt werden.
StandardModule: Modul1
Sub XL2HTML()
Dim wks As Worksheet
Dim iRow As Integer, iCol As Integer
Dim sFile As String, sPath As String
sPath = Application.Path
Close
For Each wks In ActiveWorkbook.Worksheets
wks.Select
sFile = sPath & "\" & wks.Name & ".htm"
iRow = 1
Open sFile For Output As #1
Print #1, "<html><body><table border=1>"
Do Until IsEmpty(Cells(iRow, 1))
iCol = 1
Print #1, "<tr>"
Do Until IsEmpty(Cells(1, iCol))
If Not IsEmpty(Cells(iRow, iCol)) Then
If iRow = 1 Then
Print #1, "<th>" & Cells(iRow, iCol) & "</th>"
Else
Print #1, "<td>" & Cells(iRow, iCol) & "</td>"
End If
Else
Print #1, "<td> </td>"
End If
iCol = iCol + 1
Loop
Print #1, "</tr>"
iRow = iRow + 1
Loop
Print #1, "</table></body></html>"
Close
Next wks
Worksheets(2).Select
MsgBox "Die Dateien wurden im Verzeichnis " & sPath & " gespeichert!"
End Sub