PC Review


Reply
Thread Tools Rate Thread

Bin File using VBA

 
 
dl
Guest
Posts: n/a
 
      13th Sep 2005
To delete a file from the file sytem you use the VBA command

Kill

Is there a way to rather delete and send the file to the bin/trash can on
the computer using VBA?


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th Sep 2005
Chip Pearson posted this:

You have to do it via a Windows API call -- there is no built-in VBA way to
do it.

'----------------------------------------------
Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40

Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long


Sub RecycleFile(FileName As String)
Dim lReturn As Long
Dim sFileName As String
Dim FileOperation As SHFILEOPSTRUCT

With FileOperation
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
End With

lReturn = SHFileOperation(FileOperation)

End Sub
'----------------------------------------------

Then call this with

RecycleFile FileName:="G:\Temp\Book1.xls"




dl wrote:
>
> To delete a file from the file sytem you use the VBA command
>
> Kill
>
> Is there a way to rather delete and send the file to the bin/trash can on
> the computer using VBA?


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File sort order reversed or wrong in File Open or File Save dialog box NinerSevenTango Windows XP General 1 1st Aug 2009 01:48 PM
coping file from a remote file share - FILE IS NO LONG THERE bogus error message Heith Windows Vista Networking 0 18th Oct 2007 09:58 PM
In file parsing, taking the first few characters of a text file after a readfile or streamreader file read... .Net Sports Microsoft ASP .NET 11 17th Jan 2006 12:44 AM
An Automated process of watching a network file folder, reading a file in it and deleting the file using ASP.NET ? Luis Esteban Valencia Muņoz Microsoft ASP .NET 3 4th Jun 2005 11:56 AM
i received a file that reads powerpoint document file file exten. =?Utf-8?B?Q0NBUk9MQUNFUkVD?= Microsoft Excel Misc 1 4th Dec 2004 05:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:05 AM.