Hello!
I have recently worked with Word documents as objects in vba. I have imported data from Word to access by creating arrays.
Is there a way to work with text files using the same method?
Lets say I want to get data from a line in a text file beginning with "Test:". How to I find this line and define what data to get?
The text file might look like this:
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:b Ref2:ce
Test: 20/11 03:13
Source: 1 Ref1:ef Ref2:f
Test: 20/11 03:13
Source: 1 Ref1:ab Ref2:b
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bcd
From this I would want to add data to a table with theese fileds:
Date, Time, Source, Ref1, Ref2
This means that Lines Starting with "Test:" means "create new record", and The data, time, source, ref1 and ref2 has to be picked from different lines. I know that Date always is character 7-11 in one line, and that Ref1 is charachter 34-38 in another line.....
Any ideas?
noccy
I have recently worked with Word documents as objects in vba. I have imported data from Word to access by creating arrays.
Is there a way to work with text files using the same method?
Lets say I want to get data from a line in a text file beginning with "Test:". How to I find this line and define what data to get?
The text file might look like this:
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:b Ref2:ce
Test: 20/11 03:13
Source: 1 Ref1:ef Ref2:f
Test: 20/11 03:13
Source: 1 Ref1:ab Ref2:b
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bc
Test: 20/11 03:13
Source: 1 Ref1:a Ref2:bcd
From this I would want to add data to a table with theese fileds:
Date, Time, Source, Ref1, Ref2
This means that Lines Starting with "Test:" means "create new record", and The data, time, source, ref1 and ref2 has to be picked from different lines. I know that Date always is character 7-11 in one line, and that Ref1 is charachter 34-38 in another line.....
Any ideas?
noccy
Last edited: