It is literally 5 numbers between 1 and 12 separated by commas so the numbers are entered into different cells.
i.e 1, 5, 8, 6, 12, entered into b2,c2,d2,e2 and f2 respectively.
The max msp patch will be writing data to the text file and I want the vba script to read it so that whenever the data changes the chart updates automatically. I have slightly altered the workbooka and added the chart to make it clearer
It is attached, and the code is also below. Thank you for your patience!
I will want to set up the ontime so that it checks the text file every 0.05 of a second whilst the workbook is open.
Onca again thank you very much!
MODULE 1
Option Explicit
Dim myDB As clsADODBopen
Sub Main()
Dim strCmn As String
Dim FN As String
FN = "testing.txt"
Set myDB = New clsADODBopen
strCmn = "select * from " & FN
With myDB
.subConn ThisWorkbook.Path & "\"
.subOpen strCmn
End With
subShow
Set myDB = Nothing
End Sub
Sub subShow()
Dim i As Integer, c As Long
Dim pt As Range
Set pt = ActiveSheet.Range("b2")
c = 0
With myDB.theRST
For i = 1 To .Fields.Count
If c = pt.Worksheet.Cells.Columns.Count Then
c = 0
Set pt = pt.Offset(1, 0)
End If
pt.Offset(0, c).Value = .Fields(i - 1).Name
c = c + 1
Next
'pt.Offset(1, 0).CopyFromRecordset myDB.theRST
End With
End Sub
MODULE 2
Option Explicit
Dim theCON As ADODB.Connection
Public theRST As ADODB.Recordset
Sub subConn(strFullName As String)
Dim strDrv As String
strDrv = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
" DBQ=" & strFullName & ";"
theCON.Open "Provider=MSDASQL; " & strDrv
End Sub
Sub subOpen(strCmn As String)
theRST.Open Source:=strCmn, ActiveConnection:=theCON
End Sub
Private Sub Class_Initialize()
Set theCON = New ADODB.Connection
Set theRST = New ADODB.Recordset
End Sub
Private Sub Class_Terminate()
theCON.Close
Set theRST = Nothing
Set theCON = Nothing
End Sub