Fog Creek Software
Discussion Board

Help in writing Word Macro!

Hi All,

I am planning to accomplish following:
I have several documents named like

What I want to do is take input from user about which sections he wants to have in the final document. Say user enters section1, section5 and section7.

Then I want to create a document which will be a merged copy of section1.doc, section5.doc and section7.doc.

I am not able to get this done using Word Macro. I tried looking in Merge methods but they are not offering what I am looking for.

Any help will be really appreciated!

Friday, December 5, 2003

Check out:

(tiny url equivalent: )

Start with the object model overview link. Also, I find that often I can just record a macro while stepping through a process manually, and that gets me 90% there.

Friday, December 5, 2003


The easiest way to do this is to create a master document with each of your documents as sub-documents.

Then iterate through the sub-documents merging them into the master.

Look for the following in Word's help:

'Convert a subdocument into part of the master document'

I can't remember the exact object model off the top of my head, but you should have everything you need after recording a few steps and viewing the VBA generated.

Ged Byrne
Friday, December 5, 2003

Hi Ged,

The master/sub documents idea is nifty! I have started coding the macro and it looks like it fits the bill!

Thanks for pointers!


Friday, December 5, 2003

You should see a programmer and get proper Programming Advice.


Professional Person
Friday, December 5, 2003

Professional Person,


Almost everybody else around here is.

Ged Byrne
Saturday, December 6, 2003

*  Recent Topics

*  Fog Creek Home