To the main website of James Tam Return to the CPSC 203 web page

Workbook exercise #4: Second VBA exercise for Word

Due dates for all assignments can be found on the [main grid] of the course webpage.

Note: The computer lab for CPSC 203 is located in SS018 (the "Tri-Labs"). If you find that your particular version of Word (e.g. Office 365, older versions of Office, MAC users) does not include everything needed for a feature then you should to complete that feature in SS018. Alternatively for the remote learning version of the course you can login to a lab computer from your own. [Information link created by UC-IT with modifications by James Tam, for questions: www.ucalgary.ca/it]

Introduction and tip for programming

This assignment will be more challenging than the other workbook exercise. Partly it's because the first exercise was simply to show you exactly what you need to do create and run a working VBA program, partly because this exercise is give you some actual practice writing a program that requires more than just following a bunch of steps or looking up the answer in the notes. In that way it's similar to the full assignment coming up you must think through your solution, albeit the solution for this exercise is far less complex, but it will help you prepare for writing the larger and more complex program needed for the next assignment. And it will provide you with a more realistic idea of what programming is like than the first exercise. Actual programmers don't just follow a sequence of prescribed steps or "look up an answer somewhere" when creating a computer program. Instead it requires that they understand basic programming concepts (e.g. getting user input, displaying output, using variables, branching etc.) and figuring out how to apply those concepts with the program that they must create. In a way it's analogous to creative writing. You first learn the grammar of the language. Next you study the elements associated with good writing style. Then you must determine how to apply what you have learned in order to tell a good story well - there isn't an exact sequence of steps you can apply for every situation nor can you simply lookup parts of your story someplace. Also, similar to creative writing, one gets better by 'doing'.

In the case of programming the doing means writing programs (from scratch) on your own. Examples of practice problems include: the ones listed in the course workbook, example problems covered in tutorial and lecture, suggested problems that may be described in lecture. If you have time then you can even try writing the example problems from lecture and tutorial on your own. Don't just look at the final solution! You will get more out of this process if you write a program from scratch. That program should implements the same features as the example we covered. You should do this without looking at the solution because that's just copying an answer. However you can look at the course notes and other examples to remind you of how things work in VBA.

Description

Here is a [starting document] to ensure that you at least start with the type of Word document that can contain a macro. (It doesn't contain any VBA instructions). The document is provided so you start with a Word document that can contain a macro (docm), whether or not you use it is entirely up to you. If you are unsure of what is required in the creation of a VBA program then you should refer the extra notes that you should have been taking while I covered the material to the first set of VBA lecture notes.

Below is one important reminder image of how you should save your macros (in this case the name of the Word document to contain the VBA macro is called "starting document" but your program (and the Word document that contains it) must be called "exercise4VBA").

http://pages.cpsc.ucalgary.ca/~tamj/2018/203W/assignments/assignment3/index.4.jpg

Because your macros will be included in the document, when it comes time to submit your work you can just upload the macro-enabled document. Double check that your VBA macro really is in the Word document that you upload! It is up to you to do the check, don't rely on us to do it for you.  If you want to be extra safe (and I highly recommend that you do this) you can copy paste your VBA program into a regular Word document and submit that extra Word document as well the macro-enabled document. Alternatively you can just copy-paste your VBA program from the Visual Basic editor into the exercise4VBA Word document.

It  would be a good idea to check your submission by downloading what you uploaded into D2L and actually open that document, ideally on a different computer that the one you used to write your VBA program (to help ensure that you aren't looking at a local file on the first computer which you used to write the program). As was the case with the assignments do not use other compression utilities (such as zip), otherwise your submission may not be marked.

Requirements for this exercise

Similar to the assignment everyone starts out with a grade point of zero for this exercise. As you implement the features listed below your grade will increase.

Write a VBA program called "exercise4VBA". Again: that should also be the name of your Word document as well.

To help you test your program there are 4 Word documents. Download these to folder that contains the VBA program that you are creating for this exercise. In addition to testing your program with these documents you should test your solution with test cases in other Word documents that you have made yourself to check any other cases that you might think are relevant.

You don't need to submit these 4 Word documents. The marker will have access to these documents to test your submission and may perform additional tests with other documents. But you should test your program on your own with these files because the program you need to submit will have to handle the required cases properly.

Program features and grading.

Documentation requirements

Although you won't be graded on documentation for exercises it still would be a good idea to include it so you don't miss it in the assignment. What's needed for assignments include: your full name as provided to the university (make sure it matches, don't include 'nicknames'), student identification number, tutorial number. Also you should clearly specify what features of the assignment that you completed or didn't complete. In order to get credit the documentation has to be clear and complete

Style requirements

Similar to documentation requirements you aren't graded for style for workbook exercises but it would be a good idea to still follow those requirements so you get in the habit of doing this.

  1. Each level of code indenting is consistently 1 tab. Instructions in the sub-routine (between the 'sub' and 'end-sub' is 1 level, the body of IF or WHILE structures counts as another level of indenting. An IF within an IF or WHILE within a WHILE (or even  an IF within a WHILE or a WHILE within an IF) each count as another level.
  2. Good naming conventions (e.g. variables, sub-routines, the name of Word document containing the VBA program and constants if applicable) are followed. Some examples of naming conventions are provided in [the VBA Part I notes].

Marking and grading

Collaboration:

Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others. Some "do nots" for your solution: don't publically post it, don't email it out, don't show it to other students, don't get help with your assignment from a tutor (if you have hired one).  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].

Submitting your work:

D2L configuration for this course

Late submissions for assignments  when there is no extension granted: Make sure you give yourself enough time to complete the submission process so you don't get cut off by D2L's deadline (or your submission will be automatically flagged as late by D2L and it will be graded appropriately)..

Submission received:

On time

Hours late : >0 and <=24

Hours late: >24 and <=48

Hours late: >48 and <=72

Hours late: >72 and <=96

Hours late: >96

Penalty:

None

-1 GPA

-2 GPA

-3 GPA

-4 GPA

No credit (not accepted)