I am passing a new or existing file to the sub listed below. If the file exists I want to replace it with the new data while keeping the original file name. It currently appends data to an existing file with each call to the sub. Thanks in advance
Code:
Sub SaveToFile(FileNameOrNumber As Variant)
Dim var As Variant, fnum As Integer
' store contents into a variant
var = Contents()
' store it to a file
If VarType(FileNameOrNumber) = vbString Then
fnum = FreeFile
Open FileNameOrNumber For Binary As #fnum
Put #fnum, , var
Close #fnum
Else
Put #fnum, , var
End If
End Sub