Maybe this?
Sub EF972540_ClearTextFile()
Dim fileName, toWrite As Variant
Dim fd As Office.FileDialog
Dim FS As FileSystemObject, a As TextStream
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Select the text file"
.Filters.Clear
.Filters.Add "Text Files", "*.txt", 1
If .Show = True Then
fileName = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set FS = New FileSystemObject
Set a = FS.OpenTextFile(fileName, 1)
toWrite = a.ReadLine
a.Close
Set a = FS.CreateTextFile(fileName, True)
a.WriteLine toWrite
a.Close
Set a = Nothing
Set FS = Nothing
End Sub
Bookmarks