I just ran this, and it deleted the file. The two message boxes are
trouble shooting tools and can be deleted or ignored. It is basically the
same code that you initially posted, so it could be that someone had the
file open. Or maybe you had the file open. It will not delete an open
file.
Sub dk()
myPath = ThisWorkbook.Path
fl = myPath & "\test.xls"
If Dir(fl) <> "" Then
MsgBox "It's There"
MsgBox Dir(fl)
Kill fl
End If
End Sub
And yes, the syntax using the Not operator will not work for this
application. I leaped before I looked on that one.
"Hydra" <(E-Mail Removed)> wrote in message
news:CD28C9FF-96E2-4AD5-AE9E-(E-Mail Removed)...
> This threw a type mismatch error ???
>
> strDB is Dim as string and contains the name of a valid path.
>
>
>
> "JLGWhiz" wrote:
>
>> Try it this way:
>>
>> If Not Dir(strDB) Is NothingThen
>>
>>
>>
>> "Hydra" <(E-Mail Removed)> wrote in message
>> news:1C41B05C-8E55-49F5-A582-(E-Mail Removed)...
>> > If Dir(strDB) <> "" Then
>> > Kill strDB
>> > End If
>> >
>> > Set AppAccess = CreateObject("Access.Application")
>> > AppAccess.Visible = True
>> > AppAccess.OpenCurrentDatabase strDB
>> > AppAccess.DoCmd.Opentable "MSP Data", acViewNormal, acAdd
>> >
>> > ---------------------------------------------
>> >
>> > Throws an Error cannot open the database because it is missing or opend
>> > exclusively by another user
>> >
>> >
>> > -------------------------------------------
>> >
>> >
>> > If Dir("C:\DataCheck.mdb") <> "" Then
>> > MsgBox "Datacheck Exists"
>> > Kill "C:\DataCheck.mdb"
>> > End If
>> > Set appAccess = CreateObject("Access.Application")
>> > appAccess.Visible = True
>> > With appAccess
>> > .NewCurrentDatabase ("C:\DataCheck.mdb")
>> > .Visible = True
>> >
>> > ---------------------------------------------
>> > Throws an error saying there is an existing database with this name,
>> > choose
>> > another name.
>> >
>> >
>>
>>
>>
|