When doing a simple select * query to an excel workbook, it cuts off text after 255 characters. Are recordset fields limited to 255 characters? if not, how can I get the full field text from the recordset?
The test line should have over 1400 characters
All other line items are less than 255 characters, and are correct.
Sub ExportCallLogs()
Dim conn As Object
Dim rs As Object
Dim dbpath As String
' Create the connection string.
dbpath = "mypathhere.xlsx"
' Create the Connection and Recordset objects.
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
' Open the connection and execute.
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbpath & ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"";"
conn.Open sConnString
Set rs = conn.Execute("SELECT * FROM [Sheet1$]")
' Check we have data.
If rs.EOF Then
MsgBox "Error: No records returned.", vbCritical
Exit Sub
End If
'print headers and recordset
Workbooks.Add
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1).Value = rs.Fields(i).Name
Next
Range("A2").CopyFromRecordset rs
Columns.AutoFit
Columns(i).ColumnWidth = 55
' Clean up
rs.Close
conn.Close
Set conn = Nothing
Set rs = Nothing
End Sub