+ Reply to Thread
Results 1 to 4 of 4

remove files and folders in windows

  1. #1
    Registered User
    Join Date
    06-04-2006
    Posts
    28

    remove files and folders in windows

    is it possible to put code behind a button in excel that can remove files or folders in windows?

    example:

    If I click on button1 then "c:/program files/winrar" must be deleted.

    and if its possible also empty the recycling bin.

  2. #2
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening tomro1

    The command you are looking for is "Kill" for files and "RmDir" for folders.
    Kill "c:/program files/winrar"

    This command deletes the files completely - it does not place them into the recycle bin. I suppose that fact removes the need for your next question, but just for the record the recycle bin is a Windows object so API calls are need to control it. Chip Pearson has an article here (including instuctions to place files in the recycle bin and to empty it) :

    http://www.cpearson.com/excel/Recycle.htm

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    06-04-2006
    Posts
    28
    thanks dominicb

    I also have another question but it's less ecxel related.

    If I want to remove something in "My documents"

    It is "Kill c:/documents and settings/****/my documents/picture1.jpg"

    but I don't know the account name, can you summon an account name from excel and then paste it in between the / /. Or is there another way you can go directly into my documents to kill something?

  4. #4
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening

    This is pretty much the best way to find out the location of the My Documents folder. It may seem like overkill, but remember we're into Windows territory now, so it can't be done without the API's.

    Please Login or Register  to view this content.
    HTH

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1