Thanks! mikerickson.
actually, i have created a function to identify the file availability.
below is the new function.
Sub Upload_File()
Dim Old_Path, New_Path, Main_Path As String
Old_Path = Range("V7").Value
New_Path = Range("V13").Value
Main_Path = Range("V9").Value
On Error GoTo Line1
If myFileExists(New_Path) Then
GoTo Line3
Else
End If
Line2:
'Name Old_Path As New_Path
FileCopy Old_Path, New_Path
MsgBox "File Successfully Uploaded!"
Exit Sub
Line1:
'On Error GoTo Line3
MkDir Main_Path
GoTo Line2
Line3:
MsgBox "The file could not be uploaded to SharePoint due to; either Report is already uploaded with the same Name or Allied Error."
Exit Sub
End Sub
Function myFileExists(ByVal strPath As String) As Boolean
'Function returns true if file exists, false otherwise
If Dir(strPath) > "" Then
myFileExists = True
Else
myFileExists = False
End If
End Function
Bookmarks