Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 22,467
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
 



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 09:40 PM.


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