PC Review


Reply
Thread Tools Rate Thread

copyfile method path not found

 
 
Lord Kelvan
Guest
Posts: n/a
 
      2nd Nov 2009
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 With Quote
 
 
 
 
Lord Kelvan
Guest
Posts: n/a
 
      2nd Nov 2009
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
 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      3rd Nov 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove end folder from path found with ThisWorkbook.Path command ? dim Microsoft Excel Programming 9 23rd Apr 2008 06:04 AM
Method or Data Memeber Not Found for Replacement Method Jonas Microsoft Access VBA Modules 1 22nd Nov 2007 07:20 PM
Wildcard doesn't work in copyfile method Jarryd Microsoft Access Form Coding 1 8th Dec 2005 03:12 PM
CopyFile Method problem Tim Microsoft Access VBA Modules 1 24th Aug 2004 04:02 PM
CopyFile method of FileSystemObject produces runtime error 70 phil Microsoft Access Form Coding 4 5th Oct 2003 01:38 AM


Features
 

Advertising
 

Newsgroups
 


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