Here, I got one for you:
Public Sub exportHTML()
Dim templateStream As TextStream
Dim templatePath, templateText, newFile, newText As String
Dim dataSheet As Worksheet
Dim row As Integer
'Create FileSystemObject
Dim fsObject As New FileSystemObject
'Set template file path
templatePath = "C:\template.html"
'Set sheet
Set dataSheet = Sheets("sheetname")
'If template file is exist.
If fsObject.FileExists(templatePath) Then
'Open template file
Set templateStream = fsObject.OpenTextFile(templatePath)
'Read data
templateText = templateStream.ReadAll
'Close template file
templateStream.Close
'Looping all row
For row = 2 To 4 'Here you need to modify the end row as you like
'Get new html file (filename: Range("A").html)(e.g Sample1.html)
'You can change file name.
newFile = ThisWorkbook.Path & "\" & dataSheet.Range("A" & row) & ".html"
'Set old text to new text
newText = templateText
'Set title
newText = Replace(newText, "<div class=""title""></div>", "<div class=""title"">" & dataSheet.Range("A" & row) & "</div>")
'Set date
newText = Replace(newText, "<div class=""date""></div>", "<div class=""date"">" & dataSheet.Range("B" & row) & "</div>")
'Set content
newText = Replace(newText, "<div class=""content""></div>", "<div class=""content"">" & dataSheet.Range("C" & row) & "</div>")
'Create new HTML file and open
Open newFile For Output As #1
'Write file content
Print #1, newText
'Close new file
Close
Next row
Else
Call MsgBox("Template HTML file is not exist.", vbExclamation, "Exporting HTML")
End If
End Sub
I tested with the following data:
+----------+---------+--------------------------------------+
| A | B | C |
+---+----------+---------+--------------------------------------+
| 1 | Title | Date | Content |
+---+----------+---------+--------------------------------------+
| 2 | Sample1 |20150811 | Lorem ipsum dolor |
| 3 | Sample2 |20150812 | Lorem ipsum dolor |
| 4 | Sample3 |20150813 | Lorem ipsum dolor |
+---+----------+---------+--------------------------------------+
I got the three output Sample1.html, Sample2.html, Sample3.html in the same directory with excel file with the desired content.