Your First 'Job Worthy' Program
1 - Analysis - Plan Your Work
 Lesson 3
Your First 'Job Worthy' Program

1 - Analysis - Plan Your Work

2 - Put Your Assistant To Work Again

3 - The Form Letter Macro

4 - Help!

5 - Take It One Step At A Time!


The first step in any programming project should be a careful plan of exactly what the program is intended to do. Most programmers call this analysis and it has evolved into a separate job skill, 'Analyst', with software and methods focused exclusively on this one job. In fact, the most widely used analysis method, UML (Unified Modeling Language) has been standardized by an international association, the Object Management Group (OMG). You can read through a short introduction to UML HERE.

Especially as a new programmer, you don't have to go to such great lengths. But you should take a few moments to make sure you know what you're trying to do before starting to code.

Analysis

Our Form Letter macro will substitute some text into a template document and save it. (Yes, I know that the MailMerge facility in Word does this too. First, this is a VBA Tutorial and second, it can actually be quicker sometimes to write a short program than to set up MailMerge for some things.) I've quickly sketched out a diagram showing what our program will do at the left. This should prove that it's not necessary to make your analysis very formal.

One of the purposes of this excercise is to start to train your mind to 'see' the things that need more careful consideration. For example, since the diagram shows that you will have a file in and a file out, perhaps there should be some way of providing the names of those files to the program. Maybe there ought to be a way to tell program where the files are located. And maybe there will be more than one file created at some point?

(Note: Opening the file can be a problem in testing this program, in fact. Because the program doesn't have any real file opening logic, Word can attempt to open the same file and raise an error while testing. If this happens to you, you might just try closing Word completely and restarting Word as a 'quick fix' solution.)

The same is true for our Name and 'Great Work Description' data items. How will this information be provided to the program?

Another "best practice" in analysis is that you don't have to solve the whole problem with the first program. Sometimes it's best to write a simple program that just gets you part of the way and plan on a more complete version later on. In fact, this is exactly what you do when you use the Macro Recorder to create an initial program. Our first version of the Form Letter program won't have any way to change the values filled into the form letter (partly because it's hard to simulate that with the Macro Recorder).

Although a more complex program would justify a great deal more analysis, this is enough for now. So ... lets crank up Word and the Macro Recorder again to write another program in the next section:

2 - Put Your Assistant To Work Again