Word batch combine of word docs ..

Joined
Jul 20, 2016
Messages
10
Reaction score
8
I probably posting this in wrong place.. but here goes.


What I need to do is:
1. Take a word template (master) and copy it to the top of each of 1500+ word docs that already exist.
2. Once done will copy the whole set to a new location that we need to move our repository of these 'jobdocs'.

Currently my set of jobdocs is in one location...and once done, the new docs will be copied to a new location.. and we will zip/archive the original jobdocs ..


I know it can be done.. but I wonder what way?

Please advise, and im
Paul Creamer

I dont know if this forum will notifiy on responses .. hopefully it does.
 
Last edited by a moderator:
Hi Paul, sorry I do not know the answer to your question but welcome to PCR please participate and enjoy. One of our more knowledgeable members I am sure will point you in the right direction. Once again welcome to PCR:thumb::thumb::thumb:
 
No..

Template1 - is a word doc that has various items that will need to be at the top of each of the 1300+ docs which are also word docs.

Macro makes sense..
I was hoping to loop thru a list of the jobsdocs (whether via application.documents.whatever. or similar and do some sort of insert or append. However will review the word tips u gave..

Google is my friend - hopefully i can find a answer by end of week because otherwise i will have to split 1300 to my team (5-8) or so.. and that will be interesting in its own way.
 
that word tip may get me started on possibilities:

Sub MassFormatFiles
Dim JName As String
Dialogs(wdDialogFileOpen).Show
Application.ScreenUpdating = False
JName = Dir("*.doc")
While (JName > "")
Application.Documents.Open FileName:=JName
'Do formatting here
ActiveDocument.Close SaveChanges:=wdSaveChanges
JName = Dir()
Wend
Application.ScreenUpdating = True
End Sub

I just need to figure out the 'do formatting here' where would instead do 'insert here' or similar.
 
I believe that I will need to change the 'do formatting' to be some sort 'insert here'... or similar.
right now im just playing with the existing to see if I can do similar
But at least im on track i think
 
Well still working on it.. trying to use the above shell to simply do some playing around, and not working.

I assume that it might be either:
1. was doing this on server.. probably not workable?
2.Not in proper directory - maybe..
3. still researching how to either apend or insert the template into each doc..
probably some sort of application.documents.xxxx from the objects.

At least though its good research.. will learn things as I go.
 
Well so far,
adding
Selection.InsertFile ("C:\docs\template.docx")
Seems to do do it.. but I end up with the template in the middle of the existing document instead of top of it.
Im hoping to find a way to do selection.insertbefore for a insertfile or similar.

So far attempts to insert a file continue to put the file in the first major cell of the old form.. instead above the whole form.

I will hope to find a way to tell the code to change focus or similar to have it go above the doc and not in it.. tryed insertrow but that added a row to the existing doc not above the content outside its own form.

Lovely at least im learning
 
Last edited:
Good work Paul :). I really appreciate you posting your code here, as it'll help others if no-one here knows the answer.
 
latest I stopped working ... i though I had it when it would insert ..but did it in what I would say inbetween tables (I had thought my docs were one big table).. nope.. while there is code out there to find if my selection is in a table.. I dont know yet what to do to get it to go above said table..

Exploration.

Thanks all for pointing me to possibilities.
As it is .. most of my documents are table based docs that I dont want to convert to text.
Ie; my insert and etc works great if I convert the old doc to text and do everything.
But Ive already tried reconverting the original portion back to table and its messy.
So, at the moment, my goal is to find some way of inserting my template above the existing table.
Doing range instead of selection might be better but it didnt change anything for me.
The saga continues.
 
Last edited:
Thanks all in whatever way you helped.. while I learned a lot with what was given to me.. Ive given up.

I know its doable.. but dont want to spend more than 2+ days figuring it out because I can manually do what I need in one weekend of intense edits (yea I can do 1100 of the in 2-3 days.

the only other way will be to put the template into word itself as some sort of .dot (maybe) so that I can manually add it much faster..

The bummer is that the 1100+ docs are in 50 different folders with only two folders having 800+ or so.

The erorr i get now. is that the insert does actually take template1 and inserts it but it does so in the top leftmost cell of the table in the target doc.

One thing I can go ahead and do though. is remove all the headers/footers in all docs with what I have learend anyway
 
Ah what a pain! Sorry to hear it wasn't practical to find the solution. Best of luck with all the pasting... :user:
 
hey - maybe i hit on it.

ok..when i gave up and started looking at what i had to do manually.. it hit me.. and i cant believe i didnt consider it.

note manual steps.
1. copy my template doc to clipboard
2. pull up my target doc
3. control-home (to go above the tables
4. hit <enter> once or twice - which puts original doc to page 2
5. control v --- to put my template in the original doc - page 1
6. save it

doing all this to a local copy of 1100 docs..
I found sendkeys and similar options.. but the sendkeys idea.. while it works... it doesnt work as intended within the active doc..

Similar ideas got me to a point similar to sendkeys.

Also vbKeyHome - but not yet knowing how to use it.... but figure there will be examples on the internet.

ANyway, if anybody can point me to a sendkey alternative or similar?
Mainly on how to do a control-home within vba code..

The examples i found .. didnt work.. and the only real help at work.. was a coworker suggesting i switch to using perl(windows) .. but that will take more time than doing all of it manually.


ANyway figured it was worth a post here to mention what I found, after I gave up.
Ie; I gave up, lightbulb went on..........then it went on dimmer.. rats ha
 
Last edited:
Oh great stuff Paul I am so glad you solved it and thank you for letting us know what you were doing I am sure that will help anyone else having the same problem.:thumb::thumb::thumb::thumb::user::user::user::user:
 
Thanks,
Not exactly solved.. but will note all this for a futur effort.. still going ahead with manual effort.. because I spent last 8 hrs on searching..

The examples on the internet were good.. but none of them actully work.. or worked as needed.

But at least next time I research this.. i will be a leg up. on research..
 
Back
Top