copy/rename

G

Guest

I need to copy a file c:\reports\datafile\1st471.ltr and rename it c:\reports\datafile\letter1.dbf. I need to link to letter1.dbf. I tried creating a function with the following

Function MakeDBF(
FileSystemObject.Copyfile "c:\reports\datafile\1st471.ltr", "c:\reports\datafile\letter1.dbf", tru
End Functio

I receive a 427 Runtime error
 
C

Cheryl Fischer

You do not need the FileSystemObject to copy a file; there is a built-in VBA
statement that you can use:

FileCopy "c:\reports\datafile\1st471.ltr", "c:\reports\datafile\letter1.dbf"



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Rosie said:
I need to copy a file c:\reports\datafile\1st471.ltr and rename it
c:\reports\datafile\letter1.dbf. I need to link to letter1.dbf. I tried
creating a function with the following:
Function MakeDBF()
FileSystemObject.Copyfile "c:\reports\datafile\1st471.ltr",
"c:\reports\datafile\letter1.dbf", true
 
J

Jim/Chris

Private Sub Command10_Click()
FileCopy "sourcefile", "destinationfile"
End Sub

or if the file is in use try

Private Sub Command10_Click()
Dim fso As Object
Dim boverwrite As Boolean

Set fso = CreateObject("Scripting.fileSystemObject")
fso.copyfile "sourcefile", "sourcefile"

Set fso = Nothing

End Sub

Jim
-----Original Message-----
I need to copy a file c:\reports\datafile\1st471.ltr and
rename it c:\reports\datafile\letter1.dbf. I need to link
to letter1.dbf. I tried creating a function with the following:
Function MakeDBF()
FileSystemObject.Copyfile
"c:\reports\datafile\1st471.ltr",
"c:\reports\datafile\letter1.dbf", true
 
J

Jim/Chris

Sorry the fso.copyfile should be
fso.copyfile "sourcefile", "destinationfile"

I like this because I can copy open databases

Jim
 
D

Douglas J. Steele

Just because you can copy open databases doesn't mean you should!

It's entirely possible that your copied database will be inconsistent if it
was open when you copied it, so you really shouldn't rely on it for any
purpose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top