ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Kill' (https://www.excelbanter.com/excel-programming/320212-kill.html)

solomon_monkey

'Kill'
 
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


Harald Staff

'Kill'
 
Is it asking for "save changes " ?
Also, put
DoEvents
after the Close code to give it time to complete.

HTH. Best wishes Harald

"solomon_monkey" skrev i melding
ups.com...
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




solomon_monkey

'Kill'
 
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/...69dc621880d180
Thanks


Don Guillett[_4_]

'Kill'
 
This was posted by Jim Rech:


Sub testme()


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


End Sub



--
Don Guillett
SalesAid Software

"solomon_monkey" wrote in message
ups.com...
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




Harald Staff

'Kill'
 
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

"solomon_monkey" skrev i melding
oups.com...

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/...69dc621880d180
Thanks




solomon_monkey

'Kill'
 
I can delete files manually, but it is just not liking the Kill
command. Many thanks.


Harald Staff

'Kill'
 
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

"solomon_monkey" skrev i melding
oups.com...
I can delete files manually, but it is just not liking the Kill
command. Many thanks.




solomon_monkey

'Kill'
 
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,



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com