FileCopy Problem

J

Josie

Can someone tell why this code does not work:

Dim FromDir As String, ToDir As String
Dim Source As String, Target As String

ToDir = DLookup("PropertyPath", "MyFirm")
FromDir = DLookup("PhotoPath", "MyFirm")

Source = FromDir & "\test.jpg"
MsgBox Source - folder & file name shows correct

Target = ToDir & "\test.jpg"
MsgBox Target - folder & file name shows correct

FileCopy Source, Target

Nothing is copied

Thanks in advance

Josie
 
A

Alastair MacFarlane

Josie,

The code below worked fine:

Private Function CopyMyFile()
Dim FromDir As String, ToDir As String
Dim Source As String, Target As String
FromDir = "C:\Test1"
ToDir = "C:\Test2"
Source = FromDir & "\1.bmp"
Target = ToDir & "\1.bmp"
FileCopy Source, Target
End Function

I can only assume that you have the directories the wrong
way round in your lookup table

Alastair
 
J

Josie

Alister

Thanks for the suggestion, re-looked at my code and found
that my code for the To folder was incorrect - the file
was always being copied - but into another folder!!

Josie
Had the code
 

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

Similar Threads

Why wont this code work 8
VBA - exporting serial letters to single documents 0
Moving Files 4
FileCopy problems 2
Runtime error 438 1
Filecopy problem 3
VBA macro - text replacement 0
problem with FileCopy function 1

Top