Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Delete, w/ copy to Recycle Bin

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 14 May 2006 14:27 GMT
Surely there is a way to 'kill' (delete) a document via VBA but first send a
copy of it to the recycle bin, but I'll be darned if I can figure it out. Is
there any literature on this?

Thanks,

Ed
Steve Yandl - 14 May 2006 21:36 GMT
Ed,

This short script between the dotted lines could be incorporated into a VBA
routine and used to send some file existing in a folder to the recycle bin.
The example simply sends a file named "pic.tif" that's located in "C:\Test"
to the recycle bin.  From your VBA routine, you would establish a file name,
do a SaveAs before running the code to send to the recycle bin and then
close the open document without saving changes.
_ _ _ _ _ _ _ _ _ _ _ _

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Test")
Set objFolderItem = objFolder.ParseName("pic.tif")

objFolderItem.InvokeVerb("&Delete")

_ _ _ _ _ _ _ _ _ _ _ _

The problem is that depending on the user's version of Windows and the
settings for recycle bin, the user is likely to get a dialog requesting
confirmation that they want to send the file to the recycle bin.  The script
above simply replicates what happens when you right click a file in Windows
Explorer and choose "delete" from the context menu.

I've been working on a script that would write some binary data to the
registry and toggle the setting in recycle bin on user notification off to
make it simpler to send files to the bin through code but I've not finished
yet.  Moveover, I suspect it will only work on WinXP and possibly Win2k.

Steve

> Surely there is a way to 'kill' (delete) a document via VBA but first send
> a copy of it to the recycle bin, but I'll be darned if I can figure it
[quoted text clipped - 3 lines]
>
> Ed
Ed - 16 May 2006 10:38 GMT
Steve,

   Thanks. I will give this a try.

   Roy

> Ed,
>
[quoted text clipped - 35 lines]
>>
>> Ed
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.