PC Review


Reply
Thread Tools Rate Thread

Copy Paste a file into a folder with the current date

 
 
casan.mike@gmail.com
Guest
Posts: n/a
 
      28th Oct 2008
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      28th Oct 2008
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.)





(E-Mail Removed) 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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: .bat file to copy files using current date as part of name? Terry R. Windows XP General 0 29th Oct 2008 02:23 PM
.bat file to copy files using current date as part of name? +Bob+ Windows XP General 2 29th Oct 2008 01:00 AM
Copy Paste a file into a folder with the current dat casan.mike@gmail.com Microsoft Excel Programming 1 28th Oct 2008 04:47 PM
Re: .bat file to copy files using current date as part of name? Ray Parrish Windows XP General 0 20th Oct 2008 07:28 PM
Re: .bat file to copy files using current date as part of name? Terry R. Windows XP General 0 20th Oct 2008 05:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 AM.