Hi!
Every time I read records from Database and write to a file I get this Type Mismatch error in WriteLine() line.
This time I am reading data from the Excel sheet and writing them to a file.
One of the fields has about 4 lines of text.
Other fields are read fine except that one.
I used MsgBox to send them to the screen and they works fine.
But when I use Writeline() to write to a file, it doesn't like when the field's value is a little long.
I tried using
objRs.Fields("fieldname") to get the value.
Excel sheet has values like these:
field1 field2 field3
value1 value2 value3
can someone help me why I am having mismatch error ??
********************************************
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq=C:\q\vbs\china\PatentListRev1.xls;" & _
"DefaultDir=C:\q\vbs\china"
Set objRs = CreateOBject("ADODB.RecordSet")
objRs.open "SELECT * FROM [Most Important Patents$]", objConn
Set fso = CreateObject("Scripting.FileSystemObject")
Set ofile = fso.CreateTextFile("C:\q\vbs\china\PatentReference.html")
ofile.WriteLine("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>")
ofile.WriteLine("<html><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" & _
"<title>Patents Reference - Shenandoah</title></head>")
ofile.WriteLine("<body>")
ofile.WriteLine("<table border='1' width='600'>")
Do While Not objRs.EOF
ofile.WriteLine("<tr>")
if (len(objRs.Fields(0))>0) then
temp = objRs.Fields(0)
else
temp = "---"
End If
ofile.WriteLine("<td>")
ofile.WriteLine(temp)
ofile.WriteLine("</td>")
if (len( objRs.Fields(1))>0) then
temp = objRs.Fields(1)
else
temp = "---"
End If
ofile.WriteLine("<td>")
ofile.WriteLine(temp) <===mismatch error here
ofile.WriteLine("</td>")
Every time I read records from Database and write to a file I get this Type Mismatch error in WriteLine() line.
This time I am reading data from the Excel sheet and writing them to a file.
One of the fields has about 4 lines of text.
Other fields are read fine except that one.
I used MsgBox to send them to the screen and they works fine.
But when I use Writeline() to write to a file, it doesn't like when the field's value is a little long.
I tried using
objRs.Fields("fieldname") to get the value.
Excel sheet has values like these:
field1 field2 field3
value1 value2 value3
can someone help me why I am having mismatch error ??
********************************************
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq=C:\q\vbs\china\PatentListRev1.xls;" & _
"DefaultDir=C:\q\vbs\china"
Set objRs = CreateOBject("ADODB.RecordSet")
objRs.open "SELECT * FROM [Most Important Patents$]", objConn
Set fso = CreateObject("Scripting.FileSystemObject")
Set ofile = fso.CreateTextFile("C:\q\vbs\china\PatentReference.html")
ofile.WriteLine("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>")
ofile.WriteLine("<html><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" & _
"<title>Patents Reference - Shenandoah</title></head>")
ofile.WriteLine("<body>")
ofile.WriteLine("<table border='1' width='600'>")
Do While Not objRs.EOF
ofile.WriteLine("<tr>")
if (len(objRs.Fields(0))>0) then
temp = objRs.Fields(0)
else
temp = "---"
End If
ofile.WriteLine("<td>")
ofile.WriteLine(temp)
ofile.WriteLine("</td>")
if (len( objRs.Fields(1))>0) then
temp = objRs.Fields(1)
else
temp = "---"
End If
ofile.WriteLine("<td>")
ofile.WriteLine(temp) <===mismatch error here
ofile.WriteLine("</td>")