VBA Sting Manipulation Replace Path Record 1 step

R

rebelscum0000

Dear All,

I want to replace ONLY the records which start with DIR (Check line
'HERE I WANT TO REPLACE THE PATH) for its current Path (marked with
asterisk as example) meanwhile the code populates a tbl

I am very tired, coding all night.. I hope I can explain what I want

Thanks in advance for any help you can provide me
Regards,
Antonio Macias

Example of the records in my tbl

DirHashFiles
ÿþ[Info]
Version=1
Format=MD5
Date=25.03.2008
CreatedBy=CDCheck (http://kvipu.com/CDCheck/)

[Data]
DIR Ahead\ * <Drive>:\Program Files\Ahead
453372791bf6334e4868bc0fce40518a C Program Files TO Ahead Report.txt
d41d8cd98f00b204e9800998ecf8427e C Program Files TO Ahead Temp.CRC
DIR Ahead\CoverDesigner\ * <Drive>:\Program Files\Ahead\CoverDesigner\
2adf3cb14186039d275b510452f13bb5 CoverDes.exe
eccc7c168428f9fe6e6c0ea2180770b9 CoverEdCtrl.ocx
520f42d974578eccb220a4e151e6928b def.dat
9e0dc7bae6024c0da57749bd2ad3877e NeroCoverDesigner_eng.chm
ec6828dcfe9746644cfa3b429440de5e stocks.dat
DIR Ahead\CoverDesigner\Templates\ * <Drive>:\Program Files\Ahead
\CoverDesigner\ Templates\
bd39b04133169032b795d2943d2567c2 Audio_Classic.nct
5d14806e276f8c8b786dbc6c47021fee Audio_Content.nct
541a852bf9a205910bd05e62e3670091 Audio_Title.nct
5fbcd430d1b8e38303f2793343ad3058 Audio_TitleMax.nct
c7e528396b35d9436768a85d2011857e AudioData.nct
4674167d4ea9e8cc31f1ac4f69baa888 AudioData_B&W.nct
077d1fbff6c666ac6383cb40f288081c AudioData_Classic.nct
d9094f1645443668e6cba5d7c0edfc1e AudioData_Content.nct
196c07e50ef493d1fa71dba3581ab15c DanceHiphop.nct
86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct
338a2b8947b1ea269793b9c7b735bfae Data.nct
5735eff4f4410e7ab841a439232db325 Data_B&W.nct
47ed92150ecfac4999737cb2166de0b5 Data_Classic.nct
b8926c6d538e84eb113f1a49128916fb Data_Content.nct
03d5c739e9539febe85220bd4de59cc3 Data_Title.nct
ecea1e2097553793db89aaea7a0dd6b4 Data_TitleMax.nct

This is my immediate window

GetFolder = C:\Program Files\Ahead
there are 3 Items in this string
C:
Program Files
Ahead

Drive = C
First Folder = Program Files
Last Folder = Ahead
IS <Drive>:\Folder\Folder...
C:\Program Files\Ahead\C Program Files TO Ahead Verification.txt
MyCodeSelection = 3
File Exists: = False
File Exists: = False
File Exists: = False
Batch File Exists: = False
Folder Does not exits
Folder Does not Exists
MyCodeSelection = 3
Termine el Hash
Open a Hash File in <Drive>:\Folder\Folder...
And Hash File to read is C:\Program Files\Ahead\C Program Files TO
Ahead.CRC

This is my entire code

Sub OpenWinBrowse()
Dim MyDlg As New DialogClass 'Common Dialogs Class Module for Access
and VBA
Dim vArr As Variant
Dim MyDigResponse As Integer
Dim j As Integer
Dim itemCount As Integer
Dim MyCodeSelection As Integer
Dim MyCounterDir As Integer
Dim GetFolder As String
Dim strDrive As String
Dim FirstFolder As String
Dim LastFolder As String
Dim strItems As String
Dim TempCRCFile As String
Dim TempTXTFile As String
Dim strDir As String
Dim strVerify As String
Dim newDirectory As String
Dim strHashFile As String
Dim strHashLine As String
Dim SearchDate As String
Dim SearchChar As String
Dim ccgFF As Integer
Dim egfFF As Integer
Dim amcFF As Integer
Dim jbeFF As Integer



'References:
'Microsoft DA0 3.6 Object Runtime

'Opens the Browse Dialog
With MyDlg
.TypeFile = 0 'All file Types
.TypeFile = 4 'Text Files
.DialogType = "Browse"
End With

'Show the select type of dialog selected with the properties
desired
MyDlg.Show

'Waits for the user to click a button, and returns an Integer
indicating which button
'the user clicked .DialogType = "Browse"
MyDigResponse = Len(MyDlg.ReturnFilePath)

If MyDigResponse = 0 Then
'User chose Cancel.
MsgBox "User Cancelled", vbExclamation, "Browse"
End
Else
'User Chose OK.
End If

'The name for the chosen file or directory
'Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder\Folder..
GetFolder = MyDlg.ReturnFilePath
Debug.Print "GetFolder = " & GetFolder

'Initialize New Event Split_GetFolder
'Splits The Folders in GetFolder
'Initialize Variables
vArr = Split(GetFolder, "\")

For j = 0 To UBound(vArr)
'Folders in the string separated by { \ }
If Len(vArr(j)) > 0 Then
strItems = strItems & vArr(j) & vbCr
'Debug.Print strItems
itemCount = itemCount + 1
End If
Next

Debug.Print "there are " & itemCount & " Items in this string" &
vbCr & strItems

'Manage Drive and Folders OF GetFolder
'<Drive>
strDrive = Left(vArr(0), 1)
Debug.Print "Drive = " & strDrive
'First Folder
FirstFolder = vArr(1)
Debug.Print "First Folder = " & FirstFolder
'Last Folder
LastFolder = vArr(itemCount - 1)
Debug.Print "Last Folder = " & LastFolder

'Start Event Selection_Drive_Folders
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
If itemCount = 1 Then

Debug.Print "Is <Drive>:\"
MyCodeSelection = 1
TempCRCFile = GetFolder & strDrive & " Temp" & ".CRC"
TempTXTFile = GetFolder & strDrive & " Report" & ".txt"
strDir = GetFolder & strDrive & ".CRC" 'Esto para que era?
strVerify = GetFolder & strDrive & " Verification" & ".txt"
'Esto para que era?

ElseIf itemCount = 2 Then

Debug.Print "IS <Drive>:\Folder"
MyCodeSelection = 2
TempCRCFile = GetFolder & "\" & FirstFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & FirstFolder & " Report" &
".txt"
strDir = GetFolder & "\" & FirstFolder & ".CRC" 'Esto para que
era?
strVerify = GetFolder & "\" & FirstFolder & " Verification" &
".txt" 'Esto para que era?

ElseIf itemCount >= 3 Then

Debug.Print "IS <Drive>:\Folder\Folder..."
MyCodeSelection = 3
TempCRCFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Temp" & ".CRC"
TempTXTFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & " Report" & ".txt"
strDir = GetFolder & "\" & strDrive & " " & FirstFolder & " TO
" & LastFolder & ".CRC" 'Esto para que era?
strVerify = GetFolder & "\" & strDrive & " " & FirstFolder & "
TO " & LastFolder & " Verification" & ".txt" 'Esto para que era?
Debug.Print strVerify

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

'Initialize New Event API_File_Exists
'API FileExists: Returns True of False If a File Exists
'IF FileExists = True Then Kill

If FileExists(TempCRCFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
Kill (TempCRCFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(TempTXTFile) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (TempTXTFile)
Else
Debug.Print "File Exists: = False"
End If

If FileExists(strVerify) = True Then
Debug.Print "File Exists: = True"
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO
LastFolder Report.txt
Kill (strVerify)
Else
Debug.Print "File Exists: = False"
End If

If FileExists("C:\Program Files\Dups\Batch Files\HashIt.bat") =
True Then
Debug.Print "Batch File Exists: = True"
Kill ("C:\Program Files\Dups\Batch Files\HashIt.bat")
Else
Debug.Print "Batch File Exists: = False"
End If

'Initialize New Event Writing_out_Temporal_CRC_File
'Initialize Variables

ccgFF = FreeFile()

'Writing out a Temporal .CRC file:
'<Drive>:\<Drive> Temp.CRC OR
'<Drive>\Folder\FirstFolder Temp.CRC OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Temp.CRC
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempCRCFile For Output As #ccgFF
Close #ccgFF ' Close file

'Initialize New Event Writing_out_Temporal_Report_TXT_File
'Initialize Variables

egfFF = FreeFile()

'Writing out a Temporal Report TXT file:
'<Drive>:\<Drive> Report.txt OR
'<Drive>\Folder\FirstFolder Report.txt OR
'<Drive>:\Folder\Folder...\<Drive> FirstFolder TO LastFolder
Report.txt
'In order to add this file into the Hash File without user
intervention (Writing out a Temporal batch file)

Open TempTXTFile For Output As #egfFF
Print #egfFF, "============ 00/00/0000 00:00:00 AM/PM
============"
Print #egfFF, "-- Results --"
Print #egfFF, "Info"
Print #egfFF, "- date: 00/00/0000"
Print #egfFF, "- process: Hash"
Print #egfFF, "- source: <Drive>:\<Folder>"
Print #egfFF, "- source volume label: Volume Name"
Print #egfFF, ' Write blank line.
Print #egfFF, "Basic statistics"
Print #egfFF, "- time elapsed: 00:00:00"
Print #egfFF, "- overall transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- folders processed: 000000000000"
Print #egfFF, "- files processed: 00000000000000"
Print #egfFF, "- source bytes read: 000000000000 MB
(000000000000,000000000000,000000000000 bytes)"
Print #egfFF, "- source average transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, "- source clean transfer [kB/s]:
000000000000,000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "Errors"
Print #egfFF, "- errors: 000000000000"
Print #egfFF, "- warnings: 0000000000"
Print #egfFF, "- other: 0000000000000"
Print #egfFF, ' Write blank line.
Print #egfFF, "-- Messages --"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Print #egfFF, "note;hash;Hash file created (code:
0000000000000);<Drive>:\<Folder>:\File.CRC"
Close #egfFF ' Close file.

'Initialize New Event
API_Folder_Exists_And_CreateDirectory_Nested_Folders
'API Folder Exists
'Checks IF the Folder exists, IF NOT THEN create it
If FolderExists("C:\Program Files\Dups\Batch Files") = True Then
'Folder exists
Debug.Print "Folder Exists"
Else
'API CreateDirectory Nested Folders
'Folder does not exist
Debug.Print "Folder Does not exits"
newDirectory = "C:\Program Files\Dups\Batch Files"
CreateNestedFoldersByPath (newDirectory)
Debug.Print "Folder Does not Exists"
End If

'Initialize New Event Writing_out_batch_file_CDCheck
'Initialize Variables

amcFF = FreeFile()

'Writing out a batch file (.bat or .vbs) using VBA
'Working and Tested Solution
'Determine IF is <Drive>:\ OR <Drive>:\Folder OR <Drive>:\Folder
\Folder...
'Please note: Very Sensitive if the user opens a file the hash
change
If MyCodeSelection = 1 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For
Output As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & strDrive & ".CRC" & Chr(34)
& Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & strDrive & "
Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 2 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & FirstFolder & ".CRC" &
Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & FirstFolder &
" Report" & ".txt" & Chr(34)
Close #amcFF

ElseIf MyCodeSelection = 3 Then

Open "C:\Program Files\Dups\Batch Files\HashIt.bat" For Output
As #amcFF
Print #amcFF, "CD /D " & Chr(34) & Environ("ProgramFiles")
& "\CDCheck" & Chr(34)
Print #amcFF, "START /WAIT CDCheck /CRC:MD5 " & Chr(34) &
GetFolder & Chr(34) & Chr(32) & _
"/O:" & Chr(34) & GetFolder & "\" & strDrive & " " &
FirstFolder & " TO " & LastFolder & _
".CRC" & Chr(34) & Chr(32) & _
"/SaveReport:" & Chr(34) & GetFolder & "\" & strDrive & "
" & FirstFolder & " TO " & _
LastFolder & " Report" & ".txt" & Chr(34)
Close #amcFF

End If

Debug.Print "MyCodeSelection = " & MyCodeSelection

Debug.Print "Termine el Hash"

'Initialize New Event Make_Access_Wait
'Make Access wait till It is done with other application
'MsgBox "Rutina ShellWait"
'Call ShellWait("C:\Program Files\Dups\Batch Files\HashIt.bat")
Call ShellWait("cmd.exe /c ""C:\Program Files\Dups\Batch Files
\HashIt.bat""")

'Implement a wait period in Access where the duration can be
'increased/decreased bychanging the constant to a corressponding
higher/lower value
'MsgBox "Rutina sSleep"
'Call sSleep(9000)


'Initialize New Event Read_CRC_File
'Initialize Variables

jbeFF = FreeFile()
SearchDate = "Date="

'Read All the Lines from the CRC File and Update them into the Tbl
TempData_Tbl

If itemCount = 1 Then

Debug.Print "Open a Hash File in <Drive>:\"
strHashFile = GetFolder & strDrive & ".CRC"
Debug.Print strHashFile

Debug.Print "1.- GetFolder is now " & GetFolder
Debug.Print "2.- strDrive is now " & strDrive
Debug.Print "3.- FirstFolder is now " & FirstFolder
Debug.Print "4.- LastFolder is now " & LastFolder
Debug.Print "And Hash File to read is " & strHashFile

'test it

End

Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
Debug.Print strHashLine
Loop
Close #jbeFF

ElseIf itemCount = 2 Then

Debug.Print "Open a Hash File in <Drive>:\Folder"
strHashFile = GetFolder & "\" & FirstFolder & ".CRC"
Debug.Print "And Hash File to read is " & strHashFile

'Initialize Variables
Set db = CurrentDb
Set rs = db.OpenRecordset("TempData_Tbl", dbOpenDynaset)

Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
'Debug.Print strHashLine

With rs

.AddNew 'Add a new record
'!ID = amcctr
!DirHashFiles = strHashLine
.Update 'Write the new record to the table
.Bookmark = .LastModified

End With

Loop

Close #jbeFF

ElseIf itemCount >= 3 Then

Debug.Print "Open a Hash File in <Drive>:\Folder\Folder..."
strHashFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & ".CRC"
Debug.Print "And Hash File to read is " & strHashFile

'Initialize Variables
Set db = CurrentDb
Set rs = db.OpenRecordset("TempData_Tbl", dbOpenDynaset)


'HERE I WANT TO REPLACE THE PATH
Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
'Debug.Print strHashLine

With rs

.AddNew 'Add a new record
'!ID = amcctr
!DirHashFiles = strHashLine
.Update 'Write the new record to the table
.Bookmark = .LastModified

End With

Loop

Close #jbeFF

End If

End

End Sub
 
A

Albert D. Kallal

Gee, a lot of stuff to shift through here. Could you not just posted 1 or 2
lines of the sample data???

Are the lines like:

DIR Ahead\CoverDesigner\ * <Drive>:\Program Files\Ahead\CoverDesigner\

is the aobve on a single line/reocrd???

To replace the dir path (thats after the <Drive>:, I would go:

strNewDir = "\mypath\"
strOneLine (this is assume to be the above line of text of dir ahead....)

strOneLine = split(strOneLine,"<Drive>:")
strOneLine = strOneLine & strnewDir

The only un-clear part here is do you have the parse out the Dir ahead out
of some big block of text (and, is the block of text delimited by a
vbCrLF?).
 
R

rebelscum0000

Dear Albert D. Kallal,

Yesterday I was very tired, I am sorry to post a large question, I
will try again

I want to replace ONLY the records which start with DIR when the
recordset is populating a tbl

These are the records of my actual tbl

ÿþ[Info]
Version=1
Format=MD5
Date=26.03.2008
CreatedBy=CDCheck (http://kvipu.com/CDCheck/)

[Data]
DIR Ahead\
86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct
5c17e14b80b0cb75b8c6d9147e490d9d ISOFS.dll
DIR Ahead\CoverDesigner\
2adf3cb14186039d275b510452f13bb5 CoverDes.exe
eccc7c168428f9fe6e6c0ea2180770b9 CoverEdCtrl.ocx

I want to replace this way

ÿþ[Info]
Version=1
Format=MD5
Date=26.03.2008
CreatedBy=CDCheck (http://kvipu.com/CDCheck/)

[Data]
C:\Program Files\ Ahead\
5c17e14b80b0cb75b8c6d9147e490d9d ISOFS.dll
C:\Program Files\Ahead\CoverDesigner\
2adf3cb14186039d275b510452f13bb5 CoverDes.exe
eccc7c168428f9fe6e6c0ea2180770b9 CoverEdCtrl.ocx

This is my immediate window:

GetFolder = C:\Program Files\Ahead
there are 3 Items in this string
C:
Program Files
Ahead

Drive = C
First Folder = Program Files
Last Folder = Ahead
IS <Drive>:\Folder\Folder...
Open a Hash File in <Drive>:\Folder\Folder...
strDirHashFiles C:\Program Files\
And Hash File to read is C:\Program Files\Ahead\C Program Files TO
Ahead.CRC

Thanks in advance for any help you can provide me
Regards,
Antonio Macias
 
R

rebelscum0000

Ouch! I foget a part of my code

ElseIf itemCount >= 3 Then

Debug.Print "Open a Hash File in <Drive>:\Folder\Folder..."
'Path to replace in the tbl for DIR
strDirHashFiles = strDrive & ":\" & FirstFolder & "\"
Debug.Print "strDirHashFiles " & strDirHashFiles
'Hash File to read
strHashFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & ".CRC"
Debug.Print "And Hash File to read is " & strHashFile

'Initialize Variables
Set db = CurrentDb
Set rs = db.OpenRecordset("TempData_Tbl", dbOpenDynaset)

Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
'Debug.Print strHashLine

With rs

.AddNew 'Add a new record
'!ID = amcctr
!DirHashFiles = strHashLine
.Update 'Write the new record to the table
.Bookmark = .LastModified

End With

Loop

Close #jbeFF

End If

Thanks once again for any help you can provide me
Regards,
Antonio Macias
 
A

Albert D. Kallal

You have:

Data]
DIR Ahead\
86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct
5c17e14b80b0cb75b8c6d9147e490d9d ISOFS.dll
DIR Ahead\CoverDesigner\
2adf3cb14186039d275b510452f13bb5 CoverDes.exe
eccc7c168428f9fe6e6c0ea2180770b9 CoverEdCtrl.ocx

TO:

[Data]
C:\Program Files\ Ahead\
5c17e14b80b0cb75b8c6d9147e490d9d ISOFS.dll
C:\Program Files\Ahead\CoverDesigner\
2adf3cb14186039d275b510452f13bb5 CoverDes.exe
eccc7c168428f9fe6e6c0ea2180770b9 CoverEdCtrl.ocx

The first problem in the above, is why is the DanceHiphop_B&W.nct line
missing in the output? Are you to always skip the first line of data? It not
clear as to why you are skipping this 1st line of data?

2nd issue: where does "C:\Program Files\ Ahead\" come from? is this hard
coded?

You code should simply be:

Line Input #jbeFF, strHashLine

if strHashLine = "Dir Ahead\ then
strHashLine = ""C:\Program Files\ Ahead\"
end if
... rest of code follows..

Also, when reading in the text data, is the data on one line such as:

DIR Ahead\86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct

or is it line by line such as:

DIR Ahead\
86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct

If the dir ahead\ is on one line of text, then just test for it, and replace
it as above.
And, you have to add code to skip the 2nd line of text (assuming your sample
data is correct, and the DanceHipHop_B&W.nct is supposed to be skipped as
you have above).
 
R

rebelscum0000

Dear Albert D. Kallal
The first problem in the above, is why is the DanceHiphop_B&W.nct line
missing in the output? Are you to always skip the first line of data? It not
clear as to why you are skipping this 1st line of data?

My mistake I cut and paste some records (random way), I am in a hurry
and I did not notice I missing the DanceHiphop_B&W.nct line, in this
way:
"These are the records of my actual tbl" and "I want to replace this
way"
the records are equal.
2nd issue: where does "C:\Program Files\ Ahead\" come from? is this hard
coded?
Yes

Also, when reading in the text data, is the data on one line or is it line by line such as

The line is such as:

DIR Ahead\
86c6d2e32a05f55eb4e44e33c15d83fb DanceHiphop_B&W.nct

Now, In the code in not the same if the user selects C:\, C:\ Program
Files, or C:\Program Files\Ahead\ to provide an example, the user
should be able to select any path

So I add the following code

If Left(strHashLine, 4) = "DIR " Then
strHashLine = strDirHashFiles & Mid$
(strHashLine, 5)
End If

Where the variable strDirHashFiles contains the Path to replace DIR in
the current tbl, in this case still C:\Program Files\

This is my code if the user selects <Drive>:\Folder:\Folder

ElseIf itemCount >= 3 Then

Debug.Print "Open a Hash File in <Drive>:\Folder\Folder..."
'Path to replace in the tbl for DIR (Falta Dim en caso de que
funcione)
strDirHashFiles = strDrive & ":\" & FirstFolder & "\"
Debug.Print "Path to replace in the tbl for DIR " &
strDirHashFiles
'Hash File to read
strHashFile = GetFolder & "\" & strDrive & " " & FirstFolder &
" TO " & LastFolder & ".CRC"
Debug.Print "Hash File to read is " & strHashFile

'Initialize Variables
Set ccgdb = CurrentDb
Set ccgrs = ccgdb.OpenRecordset("TempData_Tbl", dbOpenDynaset)
'IS OK How does it close it?

Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
'Debug.Print strHashLine

If Left(strHashLine, 4) = "DIR " Then
strHashLine = strDirHashFiles & Mid$
(strHashLine, 5)
End If

With ccgrs

.AddNew 'Add a new record
'!ID = amcctr
!DirHashFiles = strHashLine
.Update 'Write the new record to the table
.Bookmark = .LastModified

End With

Loop

Close #jbeFF

End If

And.... If the user selects C:\ Program Files or <Drive>:\Folder

ElseIf itemCount = 2 Then

Debug.Print "Open a Hash File in <Drive>:\Folder"
'Path to replace in the tbl for DIR (Falta Dim en caso de que
funcione)
'strDirHashFiles = strDrive & ":\" & FirstFolder & "\"
strDirHashFiles = strDrive & ":\"
Debug.Print "Path to replace in the tbl for DIR " &
strDirHashFiles
'Hash File to read
strHashFile = GetFolder & "\" & FirstFolder & ".CRC"
Debug.Print "Hash File to read is " & strHashFile

'Initialize Variables
Set ccgdb = CurrentDb
Set ccgrs = ccgdb.OpenRecordset("TempData_Tbl", dbOpenDynaset)

Open strHashFile For Input As #jbeFF
Do Until EOF(jbeFF)
Line Input #jbeFF, strHashLine
'Debug.Print strHashLine

If Left(strHashLine, 4) = "DIR " Then
strHashLine = strDirHashFiles & Mid$
(strHashLine, 5)
End If


With ccgrs

.AddNew 'Add a new record
'!ID = amcctr
!DirHashFiles = strHashLine
.Update 'Write the new record to the table
.Bookmark = .LastModified

End With

Loop

Close #jbeFF

I have tested both codes using differents paths, and it seems they are
working, but I am not complete sure about the lines I added,

Do you have another solution for me or it is ok this code for now?

Thanks in advance for any help you can provide me

Regards,
Antonio Macias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top