|
-
Jul 30th, 2002, 08:29 PM
#1
Thread Starter
Lively Member
Check to see if file exists (Resolved - thanks!)
Thank you to everyone that replied and provided solutions. I tried Beacon's and stingrae's suggestions because that way I will gain double the knowledge!!! However, I couldn't get Beacon's to work but I'm sure it was something that I did wrong. Stingrae's worked after I found the correct library to reference -- Microsoft Scripting Runtime, which is probably a necessity for all programs (this is where my VB naivity gets me!).
Ecniv -- I'll work on the Dir$ function later, I referenced the help section and it looked a bit more complicated but very useful so I'll check it out when I'm not under this intense deadline (or when I find myself in yet another pickle and have to!!!).
Once again, thanks everyone for getting me out of my newest pickle.
"I know enough VB to get myself into trouble, but not enough to get out of it!"
Take care,
Mary
************************************************
Good evening everyone!
I tried searching but can't narrow this down enough to weed through it all and I need to find this faster....
I have a report via Crystal Report designer, it's working great, and I have even managed to get it to export to Word (with the help of an earlier posting!), but if I run it a second time I get an error because the file already exists. This file can be replaced or deleted first then the new one can be created.... how can I check for the existance of the file to kill it before I export the report again?
I know it has something to do with file or system objects but that's as far as I've gotten in my haste... I will keep looking in the meantime but if someone can point me to an earlier post or something that would be greatly appreciated!!!
Thank you so much once again!!
Mary
Last edited by A441OTA; Jul 31st, 2002 at 08:14 AM.
-
Jul 30th, 2002, 09:17 PM
#2
PowerPoster
Use:
VB Code:
Private Function FileExists(ByVal sFile As String) As Boolean
'lets use this to check if the file exists before we make it hey
FileExists = CBool(Len(Dir$(sFile)))
End Function
Usage:
VB Code:
If fileexists = True then
Kill filenamehere
end if
good luck
b
-
Jul 30th, 2002, 09:44 PM
#3
Thread Starter
Lively Member
thanks Beacon!
Thanks so much Beacon, I'll try it first thing in the morning!!!
You're awesome!!!
-
Jul 31st, 2002, 01:30 AM
#4
Hyperactive Member
This works too:
Code:
Dim fso As New FileSystemObject
If fso.FileExists(sFile) = True Then
Kill sFile
End If
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
-
Jul 31st, 2002, 02:29 AM
#5
Or for the vb version ... look at the Dir$ function (although this is just a wrapper of VB for Beacons posting.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|