Bingo Vlad, thank you and Minty, added a check if file already saved, the only other thing I am not understanding after testing a few times, i have commented out the Kill statement, but the file in downloads still deletes ?
It works though but if i bypass kill, is there something i am missing here ?
Code:
Private Sub cmdDownload_Click()
Dim strdwnFile As String, strdwnPath As String, strNewFile As String, strNewPath As String
strdwnPath = Environ("USERPROFILE") & "\Downloads\"
strNewPath = "T:\DMT Ltd\Fuel Price Sheets\"
strNewFile = "Fuel Prices " & Format(Now(), "dd-mmm-yyyy") & ".xlsx"
strdwnFile = Dir(strdwnPath & "table_*.xlsx")
If Len(Dir(strNewPath & strNewFile)) > 0 Then
MsgBox ("You Already Have A File Called: " & vbNewLine & vbNewLine & _
"In: " & strNewPath & vbNewLine & vbNewLine & _
"Called: " & strNewFile), vbInformation + vbOKOnly, "FILE EXISTS"
Exit Sub
End If
If Len(Dir(strNewPath & strNewFile)) = 0 Then
If strdwnFile <> "" Then
Name strdwnPath & strdwnFile As strNewPath & strNewFile
'Kill strdwnPath & strdwnFile
Else
MsgBox ("Your File Doesn't Exist In Downloads, It Requires Downloading"), vbInformation + vbOKOnly, "NO FILE IN DOWNLOADS"
End If
End If
Application.FollowHyperlink strNewPath
Debug.Print strdwnFile
End Sub