Filecopy in vba macro

J

Jodie

Hi,

I am trying to write vba macro using Filecopy but I always
get an error (file not found) while reading the file in
the folder. Is FILECOPY are Upper or Lower case
sensitive? If yes, What is the command that uses or
interprete wether it is a lower or upper case?

here's my code:
Dim a as string
Dim b as string
atemp = "c:\temp\myfile\"
btemp = "d:\temp\yourfile\"
ctemp = "Datafile.dat"

FILECOPY atemp & ctemp, btemp & ctemp

Appreciate your help.

Thanks in advance.
Jodie
 
D

Dave Peterson

It's not case sensitive for me. (win98 now, and I've never worried about case
sensitivity in winNT, either.)

Any chance that your datafile.dat is hidden? If you go to windows explorer and
go to that folder and rightclick on the file, select properties, do you see a
check mark in the Hidden property?
 
D

Dave Peterson

Your original code worked ok for me (assuming that the FromFile actually existed
and the to folder existed). I don't have a D: drive, so I made that adjustment,
too.

How about adding a few more checks to see where it blows up:

Option Explicit
Sub testme01()

Dim aTemp As String
Dim bTemp As String
Dim cTemp As String

aTemp = "c:\temp\myfile\"
bTemp = "D:\temp\yourfile\"
cTemp = "Datafile.dat"

If Dir(aTemp & cTemp) = "" Then
MsgBox "From File is missing"
Exit Sub
End If

If Dir(bTemp & "nul") = "" Then
MsgBox "To Folder is missing"
Exit Sub
End If

FileCopy aTemp & cTemp, bTemp & cTemp

End Sub

(I changed the D: to C: for my testing. And it seemed to catch any invalid
configuration.)
 

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