I added a code to rename all the files in the directory to txt and open them and then to rename them back. try this way:
Option Explicit
Sub file()
Dim sBuf As String
Dim sTemp As String, i As Long
Dim iFileNum As Integer
Dim sFileName As String
Dim textFileName As String
sFileName = "C:\Users\Bogdan\.......\" '' <- path to the folder with gdfx files followed by "\"
renameallfiles sFileName
textFileName = Dir$(sFileName & "*.txt")
Do While textFileName <> ""
iFileNum = FreeFile()
Open sFileName & textFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
sTemp = Replace(sTemp, Range("A" & i), Range("B" & i))
Next
iFileNum = FreeFile
Open sFileName & textFileName For Output As iFileNum
Print #iFileNum, sTemp
Close iFileNum
sTemp = ""
textFileName = Dir$()
Loop
renameallfiles sFileName
MsgBox "Done!"
End Sub
Sub renameallfiles(xDir As String)
Dim xFile As String
xFile = Dir(xDir & "*")
Do Until xFile = ""
If InStr(xFile, ".txt") > 0 Then
Name xDir & xFile As xDir & Replace(xFile, ".txt", "")
Else
Name xDir & xFile As xDir & xFile & ".txt"
End If
xFile = Dir
Loop
End Sub
Bookmarks