Something like this:
Option Explicit
Sub CpyCntnt()
Dim strLine As String, strFileName As String, i As Long
strFileName = Dir("C:\Archive\" & Format(Date, "dd.m.yyyy") & "-K" & ".xml")
If strFileName = "" Then strFileName = Dir("C:\Archive\" & Format(Date, "d.mm.yyyy") & "-K" & ".xml")
If strFileName = "" Then strFileName = Dir("C:\Archive\" & Format(Date, "dd.mm.yyyy") & "-K" & ".xml")
If strFileName = "" Then
MsgBox "Dated file not found in tested formats, new one may be in use."
Exit Sub
End If
Open "C:\Archive\" & strFileName For Input As #1
i = 1
While EOF(1) = False
Line Input #1, strLine 'read the next line of data in the text file
Cells(i, 1) = strLine 'print the data in the current row
i = i + 1 'increment the row counter
Wend
Close #1
End Sub
Bookmarks