Create and Save Text file
Private Sub Update()
Dim myFileSystemObject As FileSystemObject
Dim myFile As Object
On Error Resume Next
Set myFileSystemObject = New FileSystemObject
Set myFile = myFileSystemObject.GetFile("C:\MyCust.txt")
If Err.Number = 0 Then
Set myFile = myFileSystemObject.OpenTextFile("C:\MyCust.txt", 8)
Else
Set myFile = myFileSystemObject.CreateTextFile("C:\MyCust.txt")
End If
myFile.WriteLine "File Created on: " & Date & " " & Time
myFile.Close
Set myFileSystemObject = Nothing
End Sub
Related examples in the same category