+ Reply to Thread
Results 1 to 5 of 5

VB Code to delete a file

  1. #1
    Registered User
    Join Date
    03-04-2009
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2007
    Posts
    7

    VB Code to delete a file

    I have the following code that creates a file.
    Please Login or Register  to view this content.
    this code is used to create a file that is attached to a email. After the email is sent I need code to delete the file. I tried working with
    Kill
    but could not get it figured out.
    Last edited by JahJr; 03-25-2009 at 10:06 PM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,642

    Re: VB Code to delete a file

    Hi there,

    Assuming you haven't changed either the current directory or the active worksheet since creating your temporary file, the following code should delete the temporary file:
    Please Login or Register  to view this content.
    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VB Code to delete a file

    The code can't be executing in the workbook that is ultimately deleted, because you have to close it before you kill it.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    03-04-2009
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: VB Code to delete a file

    Worked great
    Last edited by JahJr; 03-25-2009 at 09:57 PM. Reason: should be placed in a new thread

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,642

    Re: VB Code to delete a file

    Hi again,

    Many thanks for your feedback - I'm glad I was able to help.

    Regards,

    Greg M

+ 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