Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2010, 02:34 AM
Bartestokles Bartestokles is offline Merging multiple .txt's Windows XP Merging multiple .txt's Office 2003
Novice
Merging multiple .txt's
 
Join Date: Dec 2010
Posts: 3
Bartestokles is on a distinguished road
Default Merging multiple .txt's

I have hundreds, short .txt files and I'm looking for a fast way to merge them into one .doc file. Is there any way to do that?

Last edited by Bartestokles; 12-28-2010 at 03:53 AM.
Reply With Quote
  #2  
Old 12-28-2010, 04:34 AM
macropod's Avatar
macropod macropod is offline Merging multiple .txt's Windows 7 32bit Merging multiple .txt's Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Bartestokles,

Are these all just plain text files? Are they all in the same folder? Do they need to be inserted in any particular order? Is some form of separator needed between insertions in the document?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-28-2010, 04:48 AM
Bartestokles Bartestokles is offline Merging multiple .txt's Windows XP Merging multiple .txt's Office 2003
Novice
Merging multiple .txt's
 
Join Date: Dec 2010
Posts: 3
Bartestokles is on a distinguished road
Default

Hi,

Yup. Same folder, plain text and it looks like that:
Quote:
Narodowe Archiwum Cyfrowe
Sygnatura: 1-K-1508-2 (<-- that line is also their title, so no need to add pure title to this merge)
Tytuł tematu: Marian Hemar
Data: Brak daty
Miejsce:
Opis obrazu: texttexttext. Fotografia portretowa.
Autor:
Those files titles are numbers so maintain their order should be no problem if my guess is correct..?
For separator just one "free line", would be enough.
Reply With Quote
  #4  
Old 12-28-2010, 03:16 PM
macropod's Avatar
macropod macropod is offline Merging multiple .txt's Windows 7 32bit Merging multiple .txt's Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Bartestokles,

Try the following 'InsertTextFiles' macro:
Code:
Sub InsertTextFiles()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strTxt As String
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.txt", vbNormal)
While strFile <> ""
    Open strFolder & "\" & strFile For Input As #1
    strTxt = Input(LOF(1), 1)
    Close #1
    ActiveDocument.Range.InsertAfter vbCr & strTxt
    strFile = Dir()
Wend
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then
  GetFolder = oFolder.Items.Item.Path
Else
  GetFolder = ""
End If
Set oFolder = Nothing
End Function
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-29-2010, 07:30 AM
Bartestokles Bartestokles is offline Merging multiple .txt's Windows XP Merging multiple .txt's Office 2003
Novice
Merging multiple .txt's
 
Join Date: Dec 2010
Posts: 3
Bartestokles is on a distinguished road
Default

Wooah! That script is sweet Thank You very much!

As we are in that topic, let me jump in not so similar one.. sadly not even connected witch Office tools

I have 400 photos which are titled like that: 18-182-10, 21-53, 21-154 etc.
I also have 400 .txt files matched to that photos. Those titles are the same as photos titles.
In those .txt's there are
Quote:
Narodowe Archiwum Cyfrowe
Sygnatura: 18-182-10
Tytuł tematu: Marian Hemar
Data: Brak daty
Miejsce:
Opis obrazu: texttexttext. Fotografia portretowa.
Autor:
I want to take that frases from .txt's which are behind "Tytuł tematu:" and paste it/change photo titles.
Not so clearly written..
Nonetheless I hope it's possible.
Reply With Quote
  #6  
Old 12-29-2010, 01:42 PM
macropod's Avatar
macropod macropod is offline Merging multiple .txt's Windows 7 32bit Merging multiple .txt's Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Bartestokles,

It seems like we have some serious scope creep here! As you say:
Quote:
not even connected witch Office tools
I suggest you start a new thread for that - in a forum dealing with vbscript (perhaps in the 'Misc' forum here or at somewhere like http://www.tek-tips.com/threadminder.cfm?pid=329).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging or Cut and Paste AnnieM Word 1 06-24-2010 03:03 AM
Help with merging? yazakib Mail Merge 0 04-11-2010 01:24 PM
Merging Multiple Word files into One Stattovic Word 0 01-06-2010 07:19 AM
Merging Multiple Copies of the Same Document bshatto Word 0 10-19-2009 06:22 AM
2007 merging multiple documents into one master hugheso Word 0 04-02-2009 04:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:47 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