Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the below procedure called Create Path to create folders....
Dim fso As Object Sub Macro() Dim strPath As String Set fso = CreateObject("Scripting.FileSystemObject") SourceFile = "c:\1.doc" strPath = "C:\anexistingfolder\newfolder1\newfolder2\" CreatePath strPath DestinationFile = strPath & "filex.doc" fso.Copyfile SourceFile, DestinationFile End Sub Sub CreatePath(strPath As String) Dim varTemp, intTemp, strTemp varTemp = Split(strPath, "\") For intTemp = 0 To UBound(varTemp) strTemp = strTemp & varTemp(intTemp) & "\" If InStr(varTemp(intTemp), ":") = 0 And fso.FolderExists(strTemp) = False Then fso.CreateFolder strTemp End If Next End Sub If this post helps click Yes --------------- Jacob Skaria "Lord Kelvan" wrote: I am getting this error and I take it is due to the destination path does not exist is there a way to use this or another method to copy the file and create the file path in its entirety. Eg SourceFile = c:/filex.doc DestinationFile = C:/anexistingfolder/newfolder1/newfolder2/filex.doc FSO.Copyfile SourceFile, DestinationFile . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Remove end folder from path found with ThisWorkbook.Path command ? | Excel Programming | |||
Path not found error | Excel Programming | |||
Path Not Found | Excel Programming | |||
Path Not Found Error | Excel Programming | |||
Which Path not found? | Excel Programming |