ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filecopy in vba macro (https://www.excelbanter.com/excel-programming/276179-filecopy-vba-macro.html)

Jodie[_2_]

Filecopy in vba macro
 
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


Dave Peterson[_3_]

Filecopy in vba macro
 
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?

Jodie wrote:

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


--

Dave Peterson


Dave Peterson[_3_]

Filecopy in vba macro
 
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.)


Jodie wrote:

No, it's not Hidden, I am using NT.

-----Original Message-----
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?

Jodie wrote:

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


--

Dave Peterson

.


--

Dave Peterson



All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com