Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Costi ANDRITOIU Costi ANDRITOIU is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Costi ANDRITOIU[_2_] Costi ANDRITOIU[_2_] is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Costi ANDRITOIU[_2_] Costi ANDRITOIU[_2_] is offline
external usenet poster
 
Posts: 2
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can a single document have a single style with different fonts and sizes? John Dalberg Microsoft Word Help 7 March 17th 07 06:57 AM
How do i fill down in a Word table (cont. D in Excel)? Routelock Microsoft Word Help 1 October 31st 06 09:25 PM
Remove page numbers for Tbl of Cont entry? FMW Microsoft Word Help 1 August 15th 06 04:19 PM
Appending rows to protected document AngelT Tables 2 December 1st 05 05:42 PM
template appending to merged document [email protected] Mailmerge 2 August 9th 05 05:20 PM


All times are GMT +1. The time now is 12:48 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"