R
rebelscum0000
Dear all,
I have a .txt file with the following data:
A:\
C:\
C:\Downloads
C:\Dups V.1.0
C:\DVD APPZ X
C:\DVD Basic_8116
C:\HP PMD P
C:\HP PMD P II
C:\HP PMD S
C:\NO OS 80 G
D:\
E:\
I have a virgin Table called Folders with two fieldnames:
ID - Data Type: Autonumber
FoldersFound - Data Type: Text
I want to import in FoldersFound the data of the .txt file, I do not
know how to do this
In addition, I do not know which method (?) can use (DAO, ADO,
DoCmd.TransferText or ADODB (This is new for me) due my code design
I would like to use the value held in VSFLRT in order to do this task.
My code is in loop so if I can use Print #VOUF, VSFLRT and a add a new
record in my
Virgin table at the same time, maybe the code works, is this possible?
Suggestions ideas or clues are more than welcome... I am lost here!
This is the first time I am going to try to do this...
Thanks in advance
Regards,
Antonio Macias
This is my code
Sub Reading_TxtFile_R()
Dim VOTP As String 'OriginTxtPath
Dim VDTP As String 'DestinationTxtPath
Dim VRTP As String 'RenameTxtPath
Dim VTXN As String 'TxtName
Dim VINF As Integer 'InFile
Dim VOUF As Integer 'outFile
Dim VRET As String 'ReadText
Dim VSFL As String 'SearchFolderLine
Dim VDAS As String 'Documents and Settings
Dim VMSO As String 'MSOCache
Dim VPRF As String 'Program Files
Dim VWIN As String 'WINDOWS
Dim VMYC As Integer 'MyCounter
Dim VSFLR As String 'SearchFolderLineReplace
Dim VSFLRT As String 'SearchFolderLineReplaceTrim
VTXN = "LastSearch"
VSFL = "Search Folder"
VDAS = "C:\Documents and Settings"
VMSO = "C:\MSOCache"
VPRF = "C:\Program Files"
VWIN = "C:\WINDOWS"
VMYC = 0
VOTP = "C:\Program Files\Fineware\hound4\Searches\" & VTXN & ".txt"
VDTP = CurrentDb().Name
VDTP = Left$(VDTP, _
Len(VDTP) - Len(Dir$(VDTP))) & _
(VTXN & ".txt")
'Obtain legal handles
VINF = FreeFile()
Open VOTP For Input As #VINF
VOUF = FreeFile()
Open VDTP For Output As #VOUF
Do Until EOF(VINF) 'Loop until end of file.
Line Input #VINF, VRET 'Read line into variable.
'Then you can read it line by line:
'Do something with the line.
If Left(VRET, Len(VSFL)) = VSFL Then
'Counter
VMYC = VMYC + 1
'Replace
VSFLR = Replace(VRET, VSFL & _
" " & VMYC & ":", "", , , vbTextCompare)
VSFLRT = Trim(VSFLR)
'Exclusion code
If Left(VSFLRT, Len(VDAS)) = VDAS Then
ElseIf Left(VSFLRT, Len(VMSO)) = VMSO Then
ElseIf Left(VSFLRT, Len(VPRF)) = VPRF Then
ElseIf Left(VSFLRT, Len(VWIN)) = VWIN Then
Else
'Write it out
Print #VOUF, VSFLRT
End If
End If
Loop
'Tidy up
Close #VINF
Close #VOUF
I have a .txt file with the following data:
A:\
C:\
C:\Downloads
C:\Dups V.1.0
C:\DVD APPZ X
C:\DVD Basic_8116
C:\HP PMD P
C:\HP PMD P II
C:\HP PMD S
C:\NO OS 80 G
D:\
E:\
I have a virgin Table called Folders with two fieldnames:
ID - Data Type: Autonumber
FoldersFound - Data Type: Text
I want to import in FoldersFound the data of the .txt file, I do not
know how to do this
In addition, I do not know which method (?) can use (DAO, ADO,
DoCmd.TransferText or ADODB (This is new for me) due my code design
I would like to use the value held in VSFLRT in order to do this task.
My code is in loop so if I can use Print #VOUF, VSFLRT and a add a new
record in my
Virgin table at the same time, maybe the code works, is this possible?
Suggestions ideas or clues are more than welcome... I am lost here!
This is the first time I am going to try to do this...
Thanks in advance
Regards,
Antonio Macias
This is my code
Sub Reading_TxtFile_R()
Dim VOTP As String 'OriginTxtPath
Dim VDTP As String 'DestinationTxtPath
Dim VRTP As String 'RenameTxtPath
Dim VTXN As String 'TxtName
Dim VINF As Integer 'InFile
Dim VOUF As Integer 'outFile
Dim VRET As String 'ReadText
Dim VSFL As String 'SearchFolderLine
Dim VDAS As String 'Documents and Settings
Dim VMSO As String 'MSOCache
Dim VPRF As String 'Program Files
Dim VWIN As String 'WINDOWS
Dim VMYC As Integer 'MyCounter
Dim VSFLR As String 'SearchFolderLineReplace
Dim VSFLRT As String 'SearchFolderLineReplaceTrim
VTXN = "LastSearch"
VSFL = "Search Folder"
VDAS = "C:\Documents and Settings"
VMSO = "C:\MSOCache"
VPRF = "C:\Program Files"
VWIN = "C:\WINDOWS"
VMYC = 0
VOTP = "C:\Program Files\Fineware\hound4\Searches\" & VTXN & ".txt"
VDTP = CurrentDb().Name
VDTP = Left$(VDTP, _
Len(VDTP) - Len(Dir$(VDTP))) & _
(VTXN & ".txt")
'Obtain legal handles
VINF = FreeFile()
Open VOTP For Input As #VINF
VOUF = FreeFile()
Open VDTP For Output As #VOUF
Do Until EOF(VINF) 'Loop until end of file.
Line Input #VINF, VRET 'Read line into variable.
'Then you can read it line by line:
'Do something with the line.
If Left(VRET, Len(VSFL)) = VSFL Then
'Counter
VMYC = VMYC + 1
'Replace
VSFLR = Replace(VRET, VSFL & _
" " & VMYC & ":", "", , , vbTextCompare)
VSFLRT = Trim(VSFLR)
'Exclusion code
If Left(VSFLRT, Len(VDAS)) = VDAS Then
ElseIf Left(VSFLRT, Len(VMSO)) = VMSO Then
ElseIf Left(VSFLRT, Len(VPRF)) = VPRF Then
ElseIf Left(VSFLRT, Len(VWIN)) = VWIN Then
Else
'Write it out
Print #VOUF, VSFLRT
End If
End If
Loop
'Tidy up
Close #VINF
Close #VOUF