Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Test for files existing

Hi,
I have the following code courtesy of this newsgroup; what I would like to
do is check the destination folder to see if there are two files - both
..doc. if so then skip copying them since they are already there from a
previous run.

How do I check the destination folder for these files?
Thanks in advance
Sandy

MyDest = "C:\Users\Sandy\Documents\AAPGA\" _
& inputText & "\Personal Data-" & inputText & "\"

MySource = "C:\Users\Sandy\Documents\Extras\"

fn = Dir(MySource & "*.doc")

Do While fn < ""
FileCopy MySource & fn, MyDest & fn
fn = Dir()
Loop


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Test for files existing

Hi,

Maybe you could use something like this

If Dir("full path and filename") < "" Then
'file exists
Else
'file doesn't exist
End If

Mike

"Sandy" wrote:

Hi,
I have the following code courtesy of this newsgroup; what I would like to
do is check the destination folder to see if there are two files - both
..doc. if so then skip copying them since they are already there from a
previous run.

How do I check the destination folder for these files?
Thanks in advance
Sandy

MyDest = "C:\Users\Sandy\Documents\AAPGA\" _
& inputText & "\Personal Data-" & inputText & "\"

MySource = "C:\Users\Sandy\Documents\Extras\"

fn = Dir(MySource & "*.doc")

Do While fn < ""
FileCopy MySource & fn, MyDest & fn
fn = Dir()
Loop



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Test for files existing

Thing is Mike that there will always be excel files in this folder but only
ever two .doc files (if they are there) - so testing for general files is
not an option.

I would have to test for .doc files.

Sandy

"Mike H" wrote in message
...
Hi,

Maybe you could use something like this

If Dir("full path and filename") < "" Then
'file exists
Else
'file doesn't exist
End If

Mike

"Sandy" wrote:

Hi,
I have the following code courtesy of this newsgroup; what I would like
to
do is check the destination folder to see if there are two files - both
..doc. if so then skip copying them since they are already there from a
previous run.

How do I check the destination folder for these files?
Thanks in advance
Sandy

MyDest = "C:\Users\Sandy\Documents\AAPGA\" _
& inputText & "\Personal Data-" & inputText & "\"

MySource = "C:\Users\Sandy\Documents\Extras\"

fn = Dir(MySource & "*.doc")

Do While fn < ""
FileCopy MySource & fn, MyDest & fn
fn = Dir()
Loop



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Test for files existing

Sorry Mike misread what you suggested.
I will give it a go. I will let you know.
sandy

"Mike H" wrote in message
...
Hi,

Maybe you could use something like this

If Dir("full path and filename") < "" Then
'file exists
Else
'file doesn't exist
End If

Mike

"Sandy" wrote:

Hi,
I have the following code courtesy of this newsgroup; what I would like
to
do is check the destination folder to see if there are two files - both
..doc. if so then skip copying them since they are already there from a
previous run.

How do I check the destination folder for these files?
Thanks in advance
Sandy

MyDest = "C:\Users\Sandy\Documents\AAPGA\" _
& inputText & "\Personal Data-" & inputText & "\"

MySource = "C:\Users\Sandy\Documents\Extras\"

fn = Dir(MySource & "*.doc")

Do While fn < ""
FileCopy MySource & fn, MyDest & fn
fn = Dir()
Loop



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Test for files existing

hi Sandy

With Dir you can test if it exist
Something like this if this is the full path MySource & fn

If Dir(MySource & fn) < "" then
'Exist
Else
'Not exist
End If


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message ...
Hi,
I have the following code courtesy of this newsgroup; what I would like to
do is check the destination folder to see if there are two files - both
.doc. if so then skip copying them since they are already there from a
previous run.

How do I check the destination folder for these files?
Thanks in advance
Sandy

MyDest = "C:\Users\Sandy\Documents\AAPGA\" _
& inputText & "\Personal Data-" & inputText & "\"

MySource = "C:\Users\Sandy\Documents\Extras\"

fn = Dir(MySource & "*.doc")

Do While fn < ""
FileCopy MySource & fn, MyDest & fn
fn = Dir()
Loop




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
Overwriting existing files Luc Martens Excel Programming 1 November 12th 07 06:45 AM
How to test : files are already opened or not kris Excel Programming 3 July 4th 07 02:32 PM
Number format on existing files symyf Excel Discussion (Misc queries) 0 May 10th 06 05:45 PM
Hyperlink to existing files Steve Excel Programming 6 October 22nd 04 11:03 PM
Numbering files according to existing files mr Excel Programming 1 June 21st 04 03:53 PM


All times are GMT +1. The time now is 07:10 PM.

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

About Us

"It's about Microsoft Excel"