ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy a folder in VB (https://www.excelbanter.com/excel-discussion-misc-queries/134409-copy-folder-vbulletin.html)

Brettjg

Copy a folder in VB
 
Can someone help me on this one please. I want to use a macro to do backups,
but the following code work. My sub does have a different name, but surely
that doesn't matter.

Sub CopyFolder()
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
fso.CopyFolder "c:\old", "c:\new"
End Sub

Thanks, Brett

joel

Copy a folder in VB
 
This works. I changed the directory. You had "new" in the file. I think
the code you used was from a C#, or C++ compiler.

Sub CopyFolder()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder "c:\temp\old", "c:\temp\new"
End Sub


"Brettjg" wrote:

Can someone help me on this one please. I want to use a macro to do backups,
but the following code work. My sub does have a different name, but surely
that doesn't matter.

Sub CopyFolder()
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
fso.CopyFolder "c:\old", "c:\new"
End Sub

Thanks, Brett


Dave Peterson

Copy a folder in VB
 
Check your other thread for more responses.

Brettjg wrote:

Can someone help me on this one please. I want to use a macro to do backups,
but the following code work. My sub does have a different name, but surely
that doesn't matter.

Sub CopyFolder()
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
fso.CopyFolder "c:\old", "c:\new"
End Sub

Thanks, Brett


--

Dave Peterson


All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com