Manual procedure:
Template-based documents are advanced use of Writer. If you’re completely new to LO, download and read the Writer Guide.
Driving LO with BASIC macros is even more advanced usage. Unless you have a good reason for it (which you didn’t explain), begin with discovering Writer features by using them in the traditional way (“manually”). Writer is not M$ Word. It differs notably from it. You must understand these differences and master Writer features before trying macros.
To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!
This site is not a forum. Any additional information is given through editing the question. You can request explanations by commenting an answer. “Add answer” is reserved for solutions.