Results 1 to 5 of 5

Thread: consolidate a notepad by vba

  1. #1
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    consolidate a notepad by vba

    Hi,
    I have a data in a notepad, there can be 5 or 6 or 7 or more than that of notepad files (I uploaded here notepad files )
    these notepad files are located in C:\Users\WolfieeeStyle\Desktop\save it (All notepad file is located in this folder only)

    I want to consolidate it

    I have uploaded file named 1,2
    & i uploaded File 3 that is the output of the macro


    & after getting all the data from all notepad into one notepad ,delete all notepad files except the one that this macro will make and name it anything


    Thnx For the Help
    Attached Files Attached Files
    • File Type: txt 1.txt (257 Bytes, 4 views)
    • File Type: txt 2.txt (694 Bytes, 4 views)
    • File Type: txt 3.txt (959 Bytes, 4 views)

  2. #2
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    This does the job.

    Code:
    Shell Environ$("COMSPEC") & " /c  COPY ""C:\Users\WolfieeeStyle\Desktop\save it\*.txt"" ""C:\Users\WolfieeeStyle\Desktop\save it\Consolidate.txt""", vbHide

  3. #3
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    Code:
    Sub STEP3()
    Shell Environ$("COMSPEC") & " /c  COPY ""C:\Users\WolfieeeStyle\Desktop\Orders History\*.txt"" ""C:\Users\WolfieeeStyle\Desktop\Orders History\Alert..txt""", vbHide
    
    
    End Sub

    Thnx Alot Bakerman Sir For ur Great Help in solving this Problem

    But I Have One issue
    The Macro is working Perfect
    I need to add Something In the Macro
    This Macro will consolidate the notepad files & after that it should delete all the notepad files in that folder except Alert..txt files
    So Plz Help for the same & I can't use kill macro to delete the notepad files bcoz the Number of notepad file can be anything(I can't Guess how much notepad files will be there )

  4. #4
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    Code:
    Sub STEP3()
    
        Shell Environ$("COMSPEC") & " /c  COPY ""C:\Users\WolfieeeStyle\Desktop\Orders History\*.txt"" ""C:\Users\WolfieeeStyle\Desktop\Orders History\Alert..txt""", vbHide
    
        Application.Wait (Now + TimeValue("0:00:05")) 'maybe increment 5 if a lot of txt files need to be processed.
        
        Set fso = CreateObject("scripting.filesystemobject")
        
        For Each fl In fso.getfolder("C:\Users\WolfieeeStyle\Desktop\Orders History\").Files
                If fl.Name <> "Alert..txt" Then fso.deletefile fl
        Next
        
    End Sub

  5. #5
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    Thnx Alot BakerMan for helping me in solving this problem
    Problem Solved

Similar Threads

  1. Replies: 1
    Last Post: 02-19-2017, 05:14 PM
  2. Replies: 9
    Last Post: 08-23-2013, 04:25 PM
  3. Replies: 1
    Last Post: 06-07-2013, 10:32 AM
  4. Consolidate multiple workbooks from a folder into one master file VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 4
    Last Post: 02-26-2013, 09:00 PM
  5. Replies: 2
    Last Post: 12-19-2012, 08:28 AM

Tags for this Thread

Posting Permissions

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