Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default copyfile method path not found

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default copyfile method path not found

nevermind i did some more searching and found this method

Sub MakeMultiDir(FullPath As String)
Dim V As Variant
Dim N As Long
Dim S As String
V = Split(FullPath, "\")

For N = LBound(V) To UBound(V)
S = S & V(N)
If Dir(S, vbDirectory) = vbNullString Then
MkDir S
End If
S = S & "\"
Next N
End Sub

and it seems to work fine
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default copyfile method path not found

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove end folder from path found with ThisWorkbook.Path command ? dim Excel Programming 9 April 23rd 08 06:04 AM
Path not found error EAB1977 Excel Programming 6 December 9th 05 04:05 PM
Path Not Found Michael[_22_] Excel Programming 2 November 29th 03 04:21 PM
Path Not Found Error Ric Payne Excel Programming 0 October 29th 03 07:59 AM
Which Path not found? Tod Excel Programming 3 August 2nd 03 02:03 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"