|
-
Nov 25th, 2001, 11:52 AM
#1
Thread Starter
Member
Moving text files
Hi,
I need to move a text file from a directory to another.
I have the following code to do that:
Sub Manip_Files()
Dim fso As New FileSystemObject, fil1
Set fil1 = fso.GetFile("c:\testfile.txt")
fil1.Move ("c:\tmp\testfile.txt")
End Sub
It gives the error:
compile error: user-defined type not defined.
Does anybody know why?
How can I do it?
-
Nov 25th, 2001, 11:55 AM
#2
To use the FileSystemObject you have to set a reference to the Microsoft Scripting Runtime.
To set it pick Reference on the Project menu.
-
Nov 25th, 2001, 11:57 AM
#3
Member
IMHO it is also incredibly complex to use the FSO for something so simple. This seems faster, doesn't require another depedency, and is less code:
VB Code:
FileCopy "c:\testfile.txt", "c:\tmp\testfile.txt"
Kill "c:\testfile.txt"
-
Nov 25th, 2001, 12:01 PM
#4
Well you can actually use the Name statement as well.
VB Code:
Name "c:\testfile.txt" As "c:\tmp\testfile.txt"
Best regards
-
Nov 25th, 2001, 12:02 PM
#5
Thread Starter
Member
Thanks a lot.
With the reference it works.
-
Nov 25th, 2001, 12:05 PM
#6
It gives the error:
compile error: user-defined type not defined.
Have you add the Microsoft Scripting Runtime ?
-
Nov 25th, 2001, 12:08 PM
#7
Originally posted by DaoK
It gives the error:
compile error: user-defined type not defined.
Have you add the Microsoft Scripting Runtime ?
why don't you read the earlier replies first?
-
Nov 25th, 2001, 12:09 PM
#8
Why are you frustrated becasue I have read all but not this one SORRY OH MY GOD this morning you have a feeling problem or waht ?
-
Nov 25th, 2001, 12:23 PM
#9
Please do not over react. I believe he meant for you to read his first post in this thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|