+ Reply to Thread
Results 1 to 7 of 7

Deleting file obtained from VBA shell to Batch file

  1. #1
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Deleting file obtained from VBA shell to Batch file

    Hello everyone,

    I am trying to delete the batch file that's created during the process. Part of the code is as follows:
    Please Login or Register  to view this content.
    i need to delete the batch file (i.e. file_location & "BatchFile.bat") permanently once the tasks are processed.

    i am trying to use the code below to delete the batch file but it doesn't work for some reason
    Please Login or Register  to view this content.
    any suggestion guys..

    thanks in advance guys!!

    best regards
    plasma33
    Last edited by plasma33; 12-28-2014 at 07:05 AM.

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

    Re: Deleting file obtained from VBA shell to Batch file

    Good morning plasma33

    Use the Kill statement to permanently delete a file, thus :
    Please Login or Register  to view this content.
    As stated above this deletes the file, not removing it to the recycle bin, just in case.

    If you want to move it to the recycle bin (just in case!), this gets a little trickier, as it's a Windows object.
    Chip Pearson offers a solution to this here.

    HTH

    DominicB

  3. #3
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Re: Deleting file obtained from VBA shell to Batch file

    Good Morning, DominicB,

    thank you for your kind reply.

    it worked perfectly fine..i tried using the kill function before but it didn't work before...anyways its working fine now..

    i have a question regarding system refresh...do you know a vba code for a system refresh...something similar to F5 or a right click refresh type using vba macro...i tried looking on google but in vain...

    thanks again.

    best regards
    plasma33

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

    Re: Deleting file obtained from VBA shell to Batch file

    Hi plasma33

    By "system" are you referring to Excel itself?
    If so, your probably looking to recalculate everything.

    In this case, there are a few options - you could use any of the three below, depending on what scope you're after.
    Please Login or Register  to view this content.
    As I said, any of the three will do - if you do a full rebuild, it's a waste of time and resources to do any of the others as well.

    HTH

    DominicB

  5. #5
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Re: Deleting file obtained from VBA shell to Batch file

    Hi DominicB,

    thanks for a prompt reply.

    i meant by an actual system windows refresh. is there any way to do it. even an equivalent of a windows system refresh would do.

    thanks again, DominicB

    best regards
    plasma33

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

    Re: Deleting file obtained from VBA shell to Batch file

    Hi plasma33

    You're going to have to explain what you mean by a system refresh. What is it that you are not seeing that you expect to see, or vice versa?

    Unless you've been tinkering with the ScreenUpdating function, and not turned it back on (although this usually turns back on by default at the end of a routine).
    Try this :
    Please Login or Register  to view this content.
    Otherwise you need to explain why you think a "system refresh" is necessary.

    HTH

    DominicB

  7. #7
    Forum Contributor
    Join Date
    06-20-2011
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2013
    Posts
    165

    Re: Deleting file obtained from VBA shell to Batch file

    Hi Dominic,

    thank you for your reply.

    i am actually unzipping some files and then performing some tasks and then kill some files.

    but i have to refresh the desktop manually to get rid of the files. although the files are deleted but it needs a system refresh to get rid of the files. only happens for desktop though.

    i have a code which is suppose to do it but for some reason it does it for folders and not for desktop

    please find the code below:

    Please Login or Register  to view this content.
    thanks again.

    best regards
    plasma33

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need macro that opens .txt file in excel, run macros and save file in batch
    By khalidness in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2014, 11:00 AM
  2. Replies: 0
    Last Post: 01-21-2014, 10:52 AM
  3. Problem using shell to call batch file or cmd prompt
    By nickf829 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2011, 10:27 PM
  4. [SOLVED] send parameters to a batch file with the shell command
    By Marcos in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-28-2006, 03:00 PM
  5. getting vba shell command to execute batch and save output to a file
    By Mad Scientist Jr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2006, 10:10 AM

Tags for this Thread

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