Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving a folder with VBA 1

Status
Not open for further replies.

rocknrisk

Programmer
May 14, 2002
43
GB
Hi all,

Is there a way to move a folder (or file) on my system using VBA (using the file system object).

Help will be much appreciated.

Thanks in advance.
 
Hi
Have a look at this thread (thread707-268381) and use move instead of copy for the batch file solution. I can't confirm it, as I don't have the necessary help files, but I'm sure that MoveFolder is available in the FileSystemObject.
;-)
 
Might have been a bit hastey here as it doesn't work the way I was expecting.

:~/
 
I'm feeling better now!!

Sub test()
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.movefolder "c:\test", "c:\me\"
Set oFSO = Nothing
End Sub

I created the 2 folders "test" & "me" and this code moves "test" into "me" successfully. The problem I had before was omitting the "\" at the end of the destination folder.
;-)
 
Hi Loomah,

Many thanks. "Finish what you started"
 
If Loomah's solution worked, you should give it a star - click on the "Click here to mark this as a helpful or expert post" - it's the only recognition people get for helping out
G
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top