+ Reply to Thread
Results 1 to 2 of 2

VB Code in Outlook VB code to delete excel files from certain folder

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code in Outlook VB code to delete excel files from certain folder

    Hello:

    I need to add code in existing Outlook VBA to delete files MM-DD-YY_*.xls from folder C:\Temp\

    MM, dd YY will be from Todays date.

    Please let me know if you have any questions.
    Thanks.

    Riz

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: VB Code in Outlook VB code to delete excel files from certain folder

    "Air Code"
    Sub DeleteFiles()
    Dim PathName As String          ' Path to folder with file
    Dim FileName As String          ' Working file name
    Dim DateStamp As String
    
    ' initalize variables
    DateStamp = Format(Now(), "mm-dd-yy")
    PathName = "C:\Temp"
    
    FileName = Dir(PathName & "\" & DateStamp & "*_xls")
    
    While FileName <> ""
        Kill PathName & "\" & FileName
        FileName = Dir()
    Wend
    
    End Sub
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. [SOLVED] Code request to delete files from folder
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-02-2015, 11:54 PM
  3. [SOLVED] VB Code to delete files from folder
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2015, 09:25 AM
  4. Code to Run a recorded Macro in multiple excel files in specific Folder
    By john008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2015, 12:40 AM
  5. Code to Run a recorded Macro in multiple excel files in specific Folder
    By john008 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-03-2015, 11:51 PM
  6. [SOLVED] VBA Code to Move Excel files from one folder to another
    By MHamid in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-04-2013, 12:33 PM
  7. Apply the same macro code to all excel files in a folder
    By Alano in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-09-2007, 09:26 AM

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