ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Paste a file into a folder with the current date (https://www.excelbanter.com/excel-programming/419161-copy-paste-file-into-folder-current-date.html)

[email protected]

Copy Paste a file into a folder with the current date
 
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

Dave Peterson

Copy Paste a file into a folder with the current date
 
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.)





wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 10:27 AM.

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