OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-11-2005, 18:23
xombie
Guest
 
Posts: n/a
Default best way to copy and paste a file w/ vba?

Could anyone clue me in on the best way to copy and paste a file from one location to another via vba?
Ive been trying for Days, Thanx
Andy
Reply With Quote
  #2  
Old 22-11-2005, 08:38
xombie
Guest
 
Posts: n/a
Red face I think i got it but still have q's

I think i found the solution, finally. I still am unclear of a few things.
Code:
Sub testFileSystemThing()
Dim fs, 
Set fs = CreateObject("Scripting.FileSystemObject")
fs.copyfile "c:\testfile.txt", "C:\Documents and Settings\blah\Desktop\blahblah\trash\"
set fs = nothing
End Sub
1. what should i declare fs as
2. what is "scripting.FileSystemObject"
3. is it necessary to release the file system object for this application of the fso
Thanx,
Andy.
Reply With Quote
  #3  
Old 22-11-2005, 09:33
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

FileSystemObject is a nice and powerful thing but VBA provides most of the functionality pretty much natively, so you don't generally need to rely on that object.

You can use Dir function get a list of files in a folder, use FileCopy to copy a file from one location to another, use Name command to rename a file, use Kill command to delete a file, use FileAttr to get file attributes, use MkDir to create a folder and RmDir to delete a folder. There are a lot more other file functions in VBA. Just look them up in the help.

To answer your question directly, here is how you copy a file:

Code:
FileCopy "C:\FromFolder\FromFile.ext", "D:\ToFolder\ToFile.ext"
Reply With Quote
  #4  
Old 22-11-2005, 09:36
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Oh, and if you are still wondering about FileSystemObject, you can read about it here: http://msdn.microsoft.com/library/de...jsfsotutor.asp
Reply With Quote
  #5  
Old 22-11-2005, 09:45
xombie
Guest
 
Posts: n/a
Talking Thanx Alex

Thanx Alex, I will definately look into all of those options
its opened a whole new realm for me!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import / Paste Excel into CorelDraw 12 JIMXAV General 3 11-05-2007 07:11
data to textboxes VBA? olympiatr CorelDRAW/Corel DESIGNER VBA 1 27-06-2005 06:41
Transfer shapes from Draw to Paint; Using CorelScript in VB6 DWGraphics Corel Photo-Paint VBA 1 18-08-2004 20:49
Copy and paste objects in CDR9 macnab CorelDRAW/Corel DESIGNER VBA 0 03-09-2003 10:59


All times are GMT -5. The time now is 22:47.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com