Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2023, 09:45 AM
RobiNew RobiNew is offline Copy all text files in alphabetical order to a single text file Windows 10 Copy all text files in alphabetical order to a single text file Office 2016
Competent Performer
Copy all text files in alphabetical order to a single text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default Copy all text files in alphabetical order to a single text file


I'm trying to copy a number of *.TXT to a single *.TXT. The files to be copied are in alphabetical order, but in the combined file the order is different. Can someone help? Thanks!
Code:
Public Sub CombineFilesRN()
Shell Environ$("COMSPEC") & " /c Copy C:\FOLDER_RN\FOLDER30\*.txt _
 C:\FOLDER_RN\FOLDER30\TXT_TXT\CombinedFile.txt"
End Sub
Reply With Quote
  #2  
Old 12-24-2023, 02:57 PM
June7's Avatar
June7 June7 is offline Copy all text files in alphabetical order to a single text file Windows 10 Copy all text files in alphabetical order to a single text file Office 2010
Novice
 
Join Date: Nov 2023
Posts: 20
June7 is on a distinguished road
Default

Your line continuation errors when I copy/paste code. Can't break a string between lines like that. Need closing and opening quote marks and & character.

Code works for me. Data in combined file is grouped in the alphabetical order of the original file names.

You need to clarify issue.

Suggest you provide example of files as well as file names. Either as text in post or attached files.
Reply With Quote
  #3  
Old 12-24-2023, 03:17 PM
RobiNew RobiNew is offline Copy all text files in alphabetical order to a single text file Windows 10 Copy all text files in alphabetical order to a single text file Office 2016
Competent Performer
Copy all text files in alphabetical order to a single text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Sorry for the continuation error, in the original there is no break. Now I suspect that one or two txt files are not in alphabetical order because they were added later to the folder. I must find an alternative coding. Many thanks, June7!
Reply With Quote
  #4  
Old 12-25-2023, 05:04 AM
gmayor's Avatar
gmayor gmayor is offline Copy all text files in alphabetical order to a single text file Windows 10 Copy all text files in alphabetical order to a single text file Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See Insert a selection of documents which will do what you require.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 12-25-2023, 07:22 AM
RobiNew RobiNew is offline Copy all text files in alphabetical order to a single text file Windows 10 Copy all text files in alphabetical order to a single text file Office 2016
Competent Performer
Copy all text files in alphabetical order to a single text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Many thanks, Gmayor! I will certainly use your site when I need to insert a batch of files into a Word document. Season's Greetings from RobiNew.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy all text files in alphabetical order to a single text file Alphabetical order donnje Word 2 07-08-2023 06:32 AM
Note books in alphabetical order Jazz OneNote 0 08-07-2017 10:24 AM
Copy all text files in alphabetical order to a single text file Right to left text, letter order gets reversed when copy pasting. Salvia Word 1 05-26-2013 05:19 PM
O 2007 folders & files lose alphabetical order in John Seed Outlook 0 02-28-2012 05:56 PM
Copy all text files in alphabetical order to a single text file Find in alphabetical order list 14spar15 Word 1 12-03-2011 03:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft