Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I make a single document from another 500 by appending cont
Hi there,
I wonder if you guys can help me... How do I make a single word document from another let's say 500 or 1000 documents by appending their content? I have one folder with more that 400 small word documents, smaller than 1/2 page, and I want to append them in a single file, programatically. It doesn't matter the order of the documents that are appended. Any help will be appreciated. Thanks. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I make a single document from another 500 by appending cont
Hi Costi,
in principle like that: Sub Macro3() Dim strSourcePath As String Dim strDocumToAdd As String strSourcePath = "c:\test\word\" strDocumToAdd = Dir(strSourcePath & "*.doc", vbNormal) While strDocumToAdd "" ActiveDocument.Bookmarks("\endofdoc").Select Selection.InsertFile _ FileName:=strSourcePath & strDocumToAdd ActiveDocument.Save ActiveDocument.UndoClear strDocumToAdd = Dir Wend End Sub Make sure, that the actual doc is in a folder different from the folder, where all the small docs are. I've tried to keep it simple, there are many other maybe faster ways. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I make a single document from another 500 by appending cont
The boiler.dot add-in you can download from my web site will allow you to
assemble the documents in any order you like and choose whether you want each in a new section before inserting them in the current document. The following macro will simply insert each Word document, from a folder you select, one after another. If there is no docu8ment open it will create one based on normal.dot. Note unless all the short documents are based on the same template, this document will be a formatting jungle. Sub BatchInsert() Dim myFile As String Dim PathToUse As String Dim MyDoc As Document With Dialogs(wdDialogCopyFile) If .Display 0 Then PathToUse = .Directory Else MsgBox "Cancelled by User" Exit Sub End If End With If Documents.Count = 0 Then Documents.Add End If If Left(PathToUse, 1) = Chr(34) Then PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2) End If myFile = Dir$(PathToUse & "*.do?") While myFile "" Selection.InsertFile myFile myFile = Dir$() Wend End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Costi ANDRITOIU wrote: Hi there, I wonder if you guys can help me... How do I make a single word document from another let's say 500 or 1000 documents by appending their content? I have one folder with more that 400 small word documents, smaller than 1/2 page, and I want to append them in a single file, programatically. It doesn't matter the order of the documents that are appended. Any help will be appreciated. Thanks. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I make a single document from another 500 by appending
Hi guys,
Thanks a lot to both of you for your support. It went very well. It was exactly what I needed. Thanks again. Best regards, Costi ANDRITOIU "Helmut Weber" wrote: Hi Costi, in principle like that: Sub Macro3() Dim strSourcePath As String Dim strDocumToAdd As String strSourcePath = "c:\test\word\" strDocumToAdd = Dir(strSourcePath & "*.doc", vbNormal) While strDocumToAdd "" ActiveDocument.Bookmarks("\endofdoc").Select Selection.InsertFile _ FileName:=strSourcePath & strDocumToAdd ActiveDocument.Save ActiveDocument.UndoClear strDocumToAdd = Dir Wend End Sub Make sure, that the actual doc is in a folder different from the folder, where all the small docs are. I've tried to keep it simple, there are many other maybe faster ways. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do I make a single document from another 500 by appending
Thanks for your support. I managed to append all the docs in a single one.
Thanks again. Best Regards, Costi ANDRITOIU "Graham Mayor" wrote: The boiler.dot add-in you can download from my web site will allow you to assemble the documents in any order you like and choose whether you want each in a new section before inserting them in the current document. The following macro will simply insert each Word document, from a folder you select, one after another. If there is no docu8ment open it will create one based on normal.dot. Note unless all the short documents are based on the same template, this document will be a formatting jungle. Sub BatchInsert() Dim myFile As String Dim PathToUse As String Dim MyDoc As Document With Dialogs(wdDialogCopyFile) If .Display 0 Then PathToUse = .Directory Else MsgBox "Cancelled by User" Exit Sub End If End With If Documents.Count = 0 Then Documents.Add End If If Left(PathToUse, 1) = Chr(34) Then PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2) End If myFile = Dir$(PathToUse & "*.do?") While myFile "" Selection.InsertFile myFile myFile = Dir$() Wend End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Costi ANDRITOIU wrote: Hi there, I wonder if you guys can help me... How do I make a single word document from another let's say 500 or 1000 documents by appending their content? I have one folder with more that 400 small word documents, smaller than 1/2 page, and I want to append them in a single file, programatically. It doesn't matter the order of the documents that are appended. Any help will be appreciated. Thanks. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can a single document have a single style with different fonts and sizes? | Microsoft Word Help | |||
How do i fill down in a Word table (cont. D in Excel)? | Microsoft Word Help | |||
Remove page numbers for Tbl of Cont entry? | Microsoft Word Help | |||
Appending rows to protected document | Tables | |||
template appending to merged document | Mailmerge |