-
Move file by vba
check wheather file is located in C:\Users\srk\Desktop
file name is Book1.xlsb
if it located then do nothing and if not then file will be located in C:\Users\srk\Desktop\Files
move the file from here C:\Users\srk\Desktop\Files
to C:\Users\srk\Desktop
this i have to do by vba
-
Hi imrankhan!
Something like below:
Code:
Sub test()
Dim pth$, flName$
pth = "C:\Users\srk\Desktop\"
flName = "Book1.xlsb"
If Dir(pth & flName) = "" Then
Name pth & "Files\" & flName As pth & flName
End If
End Sub
-
Code:
Sub test()
Dim myFile As String
Dim pFld As String
myFile = "C:\Users\srk\Desktop\Files\Book1.xlsb"
With CreateObject("scripting.filesystemobject")
If Not .fileexists(myFile) Then Exit Sub
pFld = .getparentfoldername(.getfile(myFile).parentfolder) & "\"
If .fileexists(pFld & .getfilename(myFile)) Then Exit Sub
.MoveFile myFile, pFld
End With
End Sub
-
Thnx Mana Sir and 1976 Sir for giving ur Precious Time and Great Support to this Post
Have a Great Day Sir
Problem Solved