Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

reading textfile into word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
efqwf - 04 May 2006 21:49 GMT
How can i read with vba the content of multiple textfiles into a word
document. The structure is:
C:\Test\1.txt
C:\Test\2.txt
C:\Test\3.txt
C:\Test\4.txt

Can someone help me with that.

Willem
Helmut Weber - 04 May 2006 22:13 GMT
Hi,

quick and dirty,
in case there aren't more than 1000000 files to process, ;-)

Sub Test8970()
Dim l As Long
Dim s As String
On Error GoTo finish
For l = 1 To 10000000
  Open "c:\test\" & CStr(l) & ".txt" For Input As 1
  While Not EOF(1)
     Input #1, s
     ActiveDocument.Range.InsertAfter s & Chr(13)
  Wend
  Close #1
Next
finish:
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.