11
Views
5
Comments
[MSWordUtils] [MSWordUtils] How can I use a template to generate a word document?
mswordutils
Web icon
Forge asset by Stuart Harris
Application Type
Traditional Web

Hello,

I’d like some help with generating a Word document using a template and populating it with data.

Could you please guide me on:

  1. How to write and structure the Word template so it can be easily updated with my data.
  2. How to use the MSWordUtils functions to insert the data and generate the final document.

Thank you!

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.

It will depend on what you need.

I used as it was mentioned in the samples. They are not very useful, but explain what type of actions exist.

The only think missing is merge table cells.


Main tips:

  • For templates, bookmarks are your friends. Use them a lot.
  • You can do pages individually and merge them together later on. It will be faster to test.
UserImage.jpg
Bruna Marques

Hi,

Thank you for your response.

I’d like to know if it’s possible to define styles, such as colors, bold text, or highlights, in the Word template itself. I understand that bookmarks help identify where to insert data, but is there a way to pre-define formatting or styles in the document?

For example, I’d like to have a heading style already set to red, and then insert data from a specific column into that heading location. Is this kind of formatting possible when using MSWordUtils?

Thanks again!

2016-04-22 00-29-45
Nuno Reis
 
MVP

I think only with Bookmarks.

But you can place text with heading formatting (levels 1 to 9 by default) or define the style in real time.

It is quite complete to create new documents.


Check the sample. You create a new doc based on a template and add things there. What you have on the template will stay there.

WordUtilsSample.oml
UserImage.jpg
Bruna Marques

Hi,

Thanks for the example. I now understand how it works.

Appreciate the help!

2016-04-22 00-29-45
Nuno Reis
 
MVP

You're welcome.

I tested all Word generation options in the Forge and this is the best one by far. But there is no documentation...

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.