I have a small software that generates some Word documents. It reads a template, runs a few SqL procedures to get the data, generates the documents and then sends them via e-mail. It's quite simple.

Right now I want to apply that logic to generate another type of report, the base word template will change and it will run different queries. I can do this (wrongly) by copy pasting the code, but I want to extend the current app to generate both reports.

What I can't figure out is what software pattern I need to apply to solve this situation.