<ne***********@ gmail.com> wrote in message
news:11******** *************@i 39g2000cwa.goog legroups.com...
Hi, I have access 97. I can upgrade if I have to (but that will cost
more money :)). If I want to read a row, parse that row, and then save
the values to an HTML file, will VBA do that?
Say I want to write:
<html>
<body>
<table>
<td>
row data from table
</td>
</table>
</body>
</html>
save results as .htm for that row, go to the next, save another .htm
file....
I'm not asking anyone to write this for me. I am only asking to be
pointed in the right direction. Thank you.
I see you're not asking anyone to write it for you, but if you need to ask
whether it can be done, I'm guessing you might need a little help in getting
it done. Here is an example function which generates an html file for a
table of products. If you cut and paste the code below into a new module,
you will be able to call it like this:
If CreateProductHt ml("C:\Products .htm") Then
MsgBox "File Created",vbInfo rmation
End If
' *** Code Starts ***
Option Compare Database
Option Explicit
Public Function CreateProductHt ml(strPath As String) As Boolean
On Error GoTo Err_Handler
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim lngMaxField As Long
Dim lngCount As Long
Dim intFile As Integer
Dim strLine As String
Dim blnFileOpen As Boolean
intFile = FreeFile
If Len(Dir(strPath )) > 0 Then
If MsgBox("Overwri te existing file?" & vbCrLf & _
strPath, vbExclamation Or vbYesNoCancel) = vbYes Then
Kill strPath
Else
Exit Function
End If
End If
Open strPath For Output As #intFile
blnFileOpen = True
strSQL = "SELECT * FROM tblProduct ORDER BY ProductID"
Set dbs = CurrentDb()
Set rst = dbs.OpenRecords et(strSQL, dbOpenForwardOn ly, dbReadOnly)
If Not rst.EOF Then
lngMaxField = rst.Fields.Coun t - 1
Print #intFile, "<html>"
Print #intFile, "<head>"
Print #intFile, "<title>Pro duct List</title>"
Print #intFile, "</head>"
Print #intFile, "<body>"
Print #intFile, "<table border=2>"
While Not rst.EOF
Print #intFile, "<tr>"
For lngCount = 0 To lngMaxField
strLine = Trim(Nz(rst.Fie lds(lngCount).V alue, ""))
If Len(strLine) = 0 Then
strLine = " "
End If
strLine = "<td>" & strLine & "</td>"
Print #intFile, strLine
Next lngCount
Print #intFile, "</tr>"
rst.MoveNext
Wend
Print #intFile, "</table>"
Print #intFile, "</body>"
Print #intFile, "</html>"
CreateProductHt ml = True
End If
Exit_Handler:
If blnFileOpen Then
Close #intFile
End If
If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
If Not dbs Is Nothing Then
Set dbs = Nothing
End If
Exit Function
Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End Function
' *** Code Ends ***