dinochristou
New Member
- Joined
- Sep 7, 2011
- Messages
- 34
Good Morning All,
I have some code (below) that is returning the incorrect result when it comes to check if the file already exists.
I know its there but the check returns the result msgbox "This file does not exist."
Can anyone shed some light as to why it thinks it does not exist?
Just to mention I also tried a length result check on the same file but still does not think it exists.
I have some code (below) that is returning the incorrect result when it comes to check if the file already exists.
I know its there but the check returns the result msgbox "This file does not exist."
Can anyone shed some light as to why it thinks it does not exist?
Just to mention I also tried a length result check on the same file but still does not think it exists.
Sub SaveAs_PasteVal_Del_Email()
Dim strFileName As String
Dim iDate As String
Dim strSaveAs As String
strFileLoc = "\\BOFFIL01.Group.Net\lv26129\Test\"
'Where file will be saved
iDate = "Half Hour SL - " & Right(Date, 2) & Mid(Date, 4, 2) & Left(Date, 2)
'What the saved file will be called - issueDate
strSaveAs = strFileLoc & iDate
'full location and name of file
If Dir(strSaveAs) <> "" Then
MsgBox "This file already exists"
'& vbNewLine & "Would you like to overwrite the file?", vbYesNo, "File Exists"
Else
MsgBox "This file does not exist."
End If
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs strSaveAs, Password:="", WriteResPassword:="Password"
'Saves current active workbook in the specified location with specified name with read/write password
Call Paste_Values
'Runs PasteValues Macro
Sheets(Array("Pivots 1", "Pivots 2")).Select
ActiveWindow.SelectedSheets.Delete
'Above worksheets will be deleted
Call Hide_Sheets
'Runs Hide_Sheets macro
Call Mail_Link
'Runs Mail_Link macro
ActiveWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End Sub