Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA overwrite csv file if it was created today, else create a new one

Status
Not open for further replies.

knifey

Technical User
Nov 14, 2006
180
GB
Hi,
I have som VBA code that creates a csv file with todays date. Can anyone offer any advice on how to overwrite this csv file (without the user being prompted) if it is still the same date?
Thanks,
Roy
 
Use DisplayAlerts:
Code:
Application.DisplayAlerts=False
' SaveAs the file
Application.DisplayAlerts=True

The Kill statement before saving is an alternative method.

combo
 
I have used the following code for somthing similar

Code:
Application.DisplayAlerts = False
FileStamp = FileDateTime("\\XXXX\XXXX\XXXX\XXXXX.CSV")
FileDate = Mid(FileStamp, 1, 10)
TodayDate = Mid(Date, 1, 10)
If FileDate = TodayDate Then
	~code to save file~
end if

Application.DisplayAlerts = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top