johnny51981
Active Member
- Joined
- Jun 8, 2015
- Messages
- 406
Howdy:
I have a set of Excel Processes that I run each day, they refresh through Power Query, and then I Save As specific sheets as CSV files. The VBA provided below is how it looks now, the "FilePath" named range is currently set to a folder on my local machine.
My question is:
I would like to Save As the CSV files directly to a Shared Network Drive, but sometimes users of said CSVs leave the previous update open from the Network location (rather than moving a copy to their computer). Is there a way to run the below process if it is free to save over, but if it is held up by another user, it would Save As with a different file name, such as including the current date to the end of the file name?
I have a set of Excel Processes that I run each day, they refresh through Power Query, and then I Save As specific sheets as CSV files. The VBA provided below is how it looks now, the "FilePath" named range is currently set to a folder on my local machine.
My question is:
I would like to Save As the CSV files directly to a Shared Network Drive, but sometimes users of said CSVs leave the previous update open from the Network location (rather than moving a copy to their computer). Is there a way to run the below process if it is free to save over, but if it is held up by another user, it would Save As with a different file name, such as including the current date to the end of the file name?
VBA Code:
Sub ExportUnbilledWIP()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim TargetFolder As String
TargetFolder = Range("FilePath")
ThisWorkbook.Sheets("Unbilled WIP with Daily Excel").Copy
ActiveWorkbook.SaveAs Filename:=TargetFolder & "Unbilled WIP with Daily Excel - CUSTOMER.CSV", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
MsgBox "Unbilled WIP with Daily Excel - CUSTOMER file export is now complete"
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub