Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() How would I copy a directory(this does have things in it if that matters), for the sake of this example "C:\orig" to a new location "C:\dest" The code I have written keeps giving me an error. dim origdir as string dim destdir as string origdir = "C:\orig" destdir = "C:\dest" filecopy origdir, destdir I have also tired ending the dir strings with backslashes and that doesn't seem to work either. Thanks in advance for any help, Jason Self -- JasonSelf ------------------------------------------------------------------------ JasonSelf's Profile: http://www.excelforum.com/member.php...fo&userid=5330 View this thread: http://www.excelforum.com/showthread...hreadid=469555 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To do this kind of thing you need SHELL commands. Suggest you put your DOS
commands into a .bat file and call the file from VBA: t = Shell("command.com /c yourfile.bat") -- Gary''s Student "JasonSelf" wrote: How would I copy a directory(this does have things in it if that matters), for the sake of this example "C:\orig" to a new location "C:\dest" The code I have written keeps giving me an error. dim origdir as string dim destdir as string origdir = "C:\orig" destdir = "C:\dest" filecopy origdir, destdir I have also tired ending the dir strings with backslashes and that doesn't seem to work either. Thanks in advance for any help, Jason Self -- JasonSelf ------------------------------------------------------------------------ JasonSelf's Profile: http://www.excelforum.com/member.php...fo&userid=5330 View this thread: http://www.excelforum.com/showthread...hreadid=469555 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jason Self,
JasonSelf wrote: How would I copy a directory(this does have things in it if that matters), for the sake of this example "C:\orig" to a new location "C:\dest" The code I have written keeps giving me an error. One option is to use the FileSystemObject: Public Function gbCopyFolder(rsSourcePath As String, rsDestPath _ As String, Optional rbOverwrite As Boolean = False) As Boolean Dim fso As Object On Error GoTo ErrHandler Set fso = CreateObject("Scripting.FileSystemObject") fso.CopyFolder rsSourcePath, rsDestPath, rbOverwrite gbCopyFolder = True ExitRoutine: Set fso = Nothing Exit Function ErrHandler: Resume ExitRoutine End Function -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jason,
My interpretation is that you want a copy of the folder installed in the same directory with a new name. '------------------------------- Sub CopyFolder() 'Jim Cone - San Francisco, USA 'Requires a project reference to the "Microsoft Scripting Runtime" library. 'Copies folder, renames it and installs it in same directory. Dim objFSO As Scripting.FileSystemObject Dim objFolder As Scripting.Folder Set objFSO = New Scripting.FileSystemObject 'copy folder to the temp file. objFSO.CopyFolder "C:\orig", "C:\WINDOWS\Temp\" 'rename the copied folder. Set objFolder = objFSO.GetFolder("C:\WINDOWS\Temp\orig") objFolder.Name = "dest" 'move the copied folder back to the original directory. objFSO.MoveFolder objFolder, "C:\" Set objFolder = Nothing Set objFSO = Nothing End Sub '------------------------------- wrote in message ... How would I copy a directory(this does have things in it if that matters), for the sake of this example "C:\orig" to a new location "C:\dest" The code I have written keeps giving me an error. dim origdir as string dim destdir as string origdir = "C:\orig" destdir = "C:\dest" filecopy origdir, destdir I have also tired ending the dir strings with backslashes and that doesn't seem to work either. Thanks in advance for any help, Jason Self-- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Links - Copy a Workbook to another Directory | Excel Discussion (Misc queries) | |||
Can you copy a Excel file to a new directory and rename it? | Excel Discussion (Misc queries) | |||
Why is Word, Excel saving a backup copy in my temp directory? | Excel Discussion (Misc queries) | |||
find files and copy to new directory | Excel Programming | |||
Copy range of many files in directory. | Excel Programming |