Hi I'm trying to import dBase file to Excel. My code looks like this:
The problem is that this macro imports file with name MISS_TRX.DBF not MISS_TRXCUR.DBF. Is there a way to process file with name longer then 8.3 characters ?
Thanks for any help
Code:
Sub MFACTImport(TargetRange As Range)
DBFullName = "C:\temp\MISS_TRXCUR.DBF"
DBDirectory = "C:\temp"
TableName = "MISS_TRXCUR"
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;ReadOnly=True;Dbq=" & DBDirectory & ";"
Set rs = New ADODB.Recordset
With rs
.Open TableName, cn, adOpenStatic, adLockOptimistic, adCmdTable
For intColIndex = 0 To rs.Fields.Count - 1 ' NAZWY PÓL
TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
Next
TargetRange.Offset(1, 0).CopyFromRecordset rs ' REKORDY
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
The problem is that this macro imports file with name MISS_TRX.DBF not MISS_TRXCUR.DBF. Is there a way to process file with name longer then 8.3 characters ?
Thanks for any help
