PDA

View Full Version : consolidate a notepad by vba



fixer
07-06-2020, 11:01 PM
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

bakerman
07-07-2020, 08:21 PM
This does the job.


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

fixer
07-07-2020, 08:39 PM
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 )

bakerman
07-08-2020, 02:49 PM
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

fixer
07-08-2020, 06:41 PM
Thnx Alot BakerMan for helping me in solving this problem
Problem Solved