Saturday, December 1, 2012

Merging documents through an inclusion list with VBA

The Task

With Visual Basic for Applications (or a similar language for those who do not use Microsoft Office), merge word processing documents from a spreadsheet-based inclusion list.

Download or copy the contents from an inclusion list and three Word files:
Inclusion List Link
Sharman, Buck Link
Curry, Tom Link
Emery, Marcello Link
At this time, the inclusion list will include two worksheets. Full shows all entries that are currently being kept track of. Inclusion1 is the worksheet that you will be using for this exercise. Word files are going by a strict Last, First format… at least for now. Use the inclusion list to automatically generate a single document that combines the contents of the Word files for the two people listed into a single word processing document. Feel free to test the third person to ensure proper function.

Notes

Macros are not available for WebApps, so the free online option is insufficient for this activity. You will face similar problems if you use the Starter Edition of Office. If you really don't want to spend any money and do not already have Microsoft Office, you can try Google Docs at https://docs.google.com/. It appears that they do have a script engine. Although I am guessing that this exercise is possible with Google Docs, it is not as well set up in terms of documentation. Also, I don't think Google's approach will work quite as well for future additions to this project. If you are like me, Microsoft Office is well worth the money.

This particular exercise was inspired by a yearly directory that I have worked on. The project is tedious and is not easy to automate. Among the problems is that the specific contents of a directory entry is open to a degree of customization from the people who are being included. One idea for addressing this particular problem would be to include entries as individual files then merge them based on a list of who should be in the latest version of the directory.

To help randomize data for this project, I actually turned to a computer game called Out of the Park Baseball. I threw together a league and exported the players. This exercise features the first three players on the export. Since the data come from a sports simulation, I decided to include a uniform number. Since this is meant to be a directory, I also included where they are from. Over time, more baseball-related details could be included.

Out of the Park baseball can be found at http://www.ootpdevelopments.com/out-of-the-park-baseball/index.php.
 

Feel Free to Comment

Try to find your own unique approach and share what you are doing in the comments section. These comments can help you and others find new ideas to explore. If you are desperate enough and can't figure out how to accomplish this task, you can always ask. I do not provide space to those who visit my blog. If you would like to share any files, you are going to have to find your own online storage. At that point, you can provide links with your comments. I would like to point out that macros can create security risks. If you are going to download any solutions, make sure that you are not loading macros by default. Also, check the code before running them.


Follow-up

No comments:

Post a Comment