'Kill'

  • Thread starter Thread starter solomon_monkey
  • Start date Start date
S

solomon_monkey

Hi,

I've read and re read many posts on this subject- I do not want to
delete the file to the recycle bin just remove it completely so am
using...

Sub DeleteThisFile()

Dim DeleteFile As String

DeleteFile = ActiveWorkbook.FullName

ActiveWorkbook.Close
On Error Resume Next
kill DeleteFile

End Sub

The user need not know that the fiule is being deleted... however when
trying to run it I get the following 450 error

'Wrong number of arguments or invalid property assignment'

Am I missing something dreadfully obvious? It has been a long day...
Thanks
 
Is it asking for "save changes " ?
Also, put
DoEvents
after the Close code to give it time to complete.

HTH. Best wishes Harald
 
I will use this code as part of another sub so will incorporate save
changes into that.

Literally as I start to 'test' the macro, scrolling through using F8 it
comes up with that error and highlights the word 'kill' suggesting I am
not doing something I should...

Hmmm.... just triued it on a non networked PC and it is all well and
good... do networks make Macro;s behave as they should not? This may
explain my other undecipherable problem on

http://groups-beta.google.com/group...read/thread/42314e861a38038c/6369dc621880d180
Thanks
 
This was posted by Jim Rech:


Sub testme()


With ThisWorkbook
.Saved = True
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close SaveChanges:=False
End With


End Sub
 
I see. Well, you may have Read and Modify priviledges in network folders,
but still not be allowed to delete or replace files. This is a
Windows/administrator problem if so. Code runs under the same restrictions
as the user.

HTH. Best wishes Harald
 
I can delete files manually, but it is just not liking the Kill
command. Many thanks.
 
This is weird. Anything marked "Missing" in the Tools > References menu of
the VB editor ? (This is where ghosts and werewolves tend to hide)

Best wishes Harald
 
Visual Basic For Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library

Are the only 4 ticked... shed loads are not... nothing is marked
'missing'.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top