Copy Paste a file into a folder with the current date

C

casan.mike

Hi Guys,

I currently have a problem with the following Sub:

--------------------------------------------------------------
Sub CopyFiles()

'Create the folder with the current date
MkDir "S:\Aat\APA acc\GEOFFROY\CPI Mensuels\ALL APA Positions
\Database_" & Format(Date, "yyyymmdd")



'Copy the files created with Olympic
Set newDir = "(s:\Aat\APA acc\GEOFFROY\CPI Mensuels\ALL APA Positions
\Database_) & Format(Date, "yyyymmdd"))))
Dim SourceFile, DestinationFile
SourceFile = "Q:\Products\Aat\APA Database\Bonds Database
\fapa_bonds.xls" ' Define source file name.
DestinationFile = newDir
FileCopy SourceFile, DestinationFile ' Copy source to target.


End Sub
--------------------------------------------------------------

I managed to create the folder with the current date but I can't move
the file to the new folder since the line
Set newDir = ...
gives an error

I am a beginner so I dunnot master the "" and the (), so please be
nice with me :)

Thanks a lot guys, hope I will help you one day,

Mike
 
D

Dave Peterson

NewDir is a string variable. You don't use the Set statement with that kind of
variable. (You only use Set with object variables.)

ps. Don't include the ()'s in this statement:

newDir = "s:\Aat\APA acc....

And I'd change those commands around a bit:

newdir = "S:\aat\..._" & Format(Date, "yyyymmdd")

then
mkdir newdir

(instead of having to type it out again.)
 

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