silentwolf
Active member
- Local time
- Today, 11:05
- Joined
- Jun 12, 2009
- Messages
- 644
Hi guys,
not sure why this code is not displaying data from CopyFromRecordset.
If I add the Value "Test" it workes but it does not display the data from the Recordset?
Just not sure why it does that?
Does anyone can spot the Problem?
No Error Message it runs through not a problem but just don't display the data from the given File.
Thanks for assistance!
not sure why this code is not displaying data from CopyFromRecordset.
Code:
Private m_appExcel As Excel.Application
Private m_wkbExcel As Excel.Workbook
Private m_wksExcel As Excel.Worksheet
Private m_wksRange As Excel.Range
'
Code:
Sub GetDataFromCSV()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=Y:\BUSINESS\Data\2021\;" & _
"Extensions=asc,csv,tab,txt;"
cn.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
rs.Source = "SELECT * FROM [OktbisDez2021.csv]"
rs.Open
Set m_appExcel = HoleAnwendung("Excel.Application")
Set m_wkbExcel = m_appExcel.Workbooks.Add
Set m_wksExcel = m_wkbExcel.Worksheets(1)
Set m_wksRange = m_wksExcel.Range("A2")
' m_wksRange.Value = "Test"
m_wksRange.CopyFromRecordset rs
m_appExcel.Visible = True
rs.Close
cn.Close
End Sub
If I add the Value "Test" it workes but it does not display the data from the Recordset?
Just not sure why it does that?
Does anyone can spot the Problem?
No Error Message it runs through not a problem but just don't display the data from the given File.
Thanks for assistance!