Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
use current file and folder name mohavv Excel Discussion (Misc queries) 1 December 19th 07 10:06 PM
Macro to open most current file in folder Tasha Excel Discussion (Misc queries) 6 June 19th 07 03:36 PM
Copy/Paste dates from CSV file - date format error? michael.beckinsale Excel Programming 6 May 12th 07 11:05 AM
reference to current file path/folder name? Edreams Excel Programming 1 October 27th 05 05:28 PM
Copy folder and paste to another folder ddiicc Excel Programming 4 July 21st 05 02:47 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"