#1
|
|||
|
|||
Generating Multiple Word Docs from Master Depending on Conditions
Hello! I'm pretty new to VBA and will do my best to explain what it is I am trying to do.
I have one Master word document, that I want to use to generate 21 new word documents (each for a different account). The master document contains a large amount of text, but some of the text varies between accounts. Whenever there is a text that varies for each account, it is highlighted in the master with [AccountName] right after it, so this text should go into the new document for that particular account. I know this is probably a very vague question, but tips and or pertinent reading materials would be very helpful. Cheers! |
#2
|
||||
|
||||
Instead of using what you're calling a 'Master word document', you should be using a Word template. Templates are used for creating documents. As for the variable text, you could add a custom document property, like 'AccountName' to the template and, when you create a new document from it, simply add the relevant details to that property. Then, in the document itself, you could use field coding to conditionally show/hide the related content. Such fields might be coded as:
{IF{DOCPROPERTY AccountName}= "Company A" "Conditional content for Company A"} Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Alternatively, if whatever you're producing relates to an Excel workbook or a DATABASE that can supply the company data, you might use a mailmerge. Without knowing more about your specific requirements, it's difficult to give tailored advice.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you so much! That seems like a great place to start.
|
#4
|
|||
|
|||
Hi- replying back to this, I have been working with mail merge the last few days to accomplish the process of turning a template into 20 varied forms, and it's been a bit of a mess (mainly issues with hyperlinks and formatting, bullet points, too many blank lines).
Essentially I have a 'Guideline' document, that has the same formatting and much of the same text across all accounts, but also a large amount of varied text and links. What I have done is make an excel spreadsheet and input each account as a row, and then across column coded it so that I can import this data through mail merge, and populate text conditionally. I would like the final form to be user friendly if someone has to make changes to the form itself, but mail merge seems rather un-user friendly. Any other suggestions? Thanks! |
#5
|
||||
|
||||
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
My boss thinks this might be inefficient because we would have to fill in the custom properties (there are about 40) for each of the 20 documents. Can you link me to somewhere where I can read more about this method though? Thanks!
Moreover, in some cases, entire paragraphs are different, it's not just an insert ____here type thing. But, I'm not sure if this makes a difference. |
#7
|
||||
|
||||
The number of conditional paragraphs, etc. is irrelevant. A single custom document property, like 'AccountName', can be used to vary the content in multiple locations. you can have as many fields coded along the lines of:
{IF{DOCPROPERTY AccountName}= "Company A" "Conditional content for Company A"} as you want. Such fields can contain multiple paragraphs, tables, images, etc. Thus, the first such field for Company A might contain: {IF{DOCPROPERTY AccountName}= "Company A" "First conditional content for Company A"} the second one: {IF{DOCPROPERTY AccountName}= "Company A" "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna."} the third one: {IF{DOCPROPERTY AccountName}= "Company A" "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci."} and so on. If more than one of the existing documents are always produced for a given account name (or account type), those documents could be combined into one, so that all of them are produced in one go. You'd then only need to print the relevant Section(s) at any given time. Unless you can be clearer about your requirements, one can only speak in general terms. That said, for an idea of how much can be automated, take a look at: https://www.msofficeforums.com/word-...drop-down.html https://www.msofficeforums.com/word-...own-lists.html http://answers.microsoft.com/en-us/o...2-9ae21837494a https://www.msofficeforums.com/word-...html#post85712
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
from text to table, with conditions depending on format | Marco | Word VBA | 2 | 10-29-2015 06:40 PM |
Use multiple style sets in the same Word document (depending on which section the style is in) | Ricyteach | Word VBA | 6 | 03-09-2015 07:11 PM |
Add watermark to multiple word docs | mykeee | Word | 1 | 09-21-2013 04:01 PM |
How do you update your source docs from a master document? | Joyce | Word | 3 | 07-12-2013 08:54 AM |
Amend footer in multiple word docs? | compact | Word | 2 | 02-24-2009 09:40 AM |