- Code: Select all
Sub activateall()
Dim strLoad As String
strLoad = Dir("C:\project\*.txt")
Do While strLoad > vbNullString
'code goes here to import into excel
Workbooks.OpenText Filename:= _
strLoad, Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3 _
, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1))
strLoad = Dir
Loop
End Sub
Above is my code for opening up all textfiles in a folder located in D:\project in excel. I had hundred of files and all the files name have 36 characters. I need to modify the VB6 script to do the following:
1) I need to open up the text files so that certain data can be copied over to another excel sheet
2) The script must be able to open up files that share a similar first 13 characters FIRST so that data can be copied over to the excel sheet.
3) After the required data had been copied, the script should be able to search for another pair of files that also share a similar first 13 characters.
4) The whole process will continue till the last pair is being search. Those files without a pair will not be open in excel
Can anyone provide me with a modification to the code?


