Skip to main content

Tag Building in Microsoft Word, The Tag Builder


This tutorial introduces the three most commonly used Windward tags: the two [ForEach] tags and the [out] tag.


After completing this tutorial you will have learned how to work with basic Windward tags.


After you have connected to a data source, you may begin adding tags, or placeholders for data, to your report template. When you look at a template, you usually can tell an item is a tag and not just a piece of text by its surrounding square brackets [ ].

There are ten standard tags and seven advanced tags in AutoTag. This tutorial introduces the three most commonly used tags: the two [ForEach] tags and the [out] tag.

Note: This tutorial covers both XML and SQL data sources, and the examples shown here use the sample data source Northwind. You can "play along" with this tutorial by using the Northwind XML file that ships with AutoTag. Or, you can follow these steps with your organization's own data sources, keeping in mind that your specific choices (data source location, server name, database name, data groups, etc.) will be different from what's listed here.


Create a table in Word

The Tag Builder lets us create a table from scratch. While we won't cover all the features here, this will give you a peek at the Tag Builder's capabilities.

Before we can begin placing tags in the template, we need to know where they will go. As we did in the Data Bin example, we'll be creating a table of employees. This one will have columns for the employee ID, the employee last name, the employee first name, and an additional column, job title.


Use Word's standard table tools to create a 4 by 2 table:



We chose this size because it gives us one column for each data category. In the first row we will place the data titles, and in the second row we will place the tags. You do not need to know how many rows of data will be output when you run the report; AutoTag takes care of expanding that for you automatically.

In the table's first row enter the column headings, and then format the table using Word's commands:


blank word table.PNG

Open the Tag Builder


 Click the first cell in the second row of the table and click the Tag Builder button in AutoTag:


Tag Builder Button.PNG

This opens the Tag Editor (which is the same window that appears when you double click an existing tag):

Tag Builder with XML.PNG

Create a [ForEach] tag

In the Tag Editor, click the Tags tab:


tag builder out and foreach.PNG

Click the [ForEach] Tag icon.

Set the tag's properties

Click the Select tab. Here is where you will set the characteristics of the tag.

First, we must choose what data will be called upon by the [ForEach] tag. Since we'll be creating a table of data from subgroups of the Employees data group, that's the group we want to loop through.  Click the Employees data group in the Data Source pane, and drag and drop that group into the Select Bar.

Second, we must name the [ForEach] tag, because if we don't, we cannot save it. We'll call this tag "EmployeeList." In the Attributes pane, click the var text box, and type the desired name (EmployeeList) in the text box:


foreach  tag attributes.PNG


We could also define other characteristics of the tag now -- there are many options to choose from -- but we will keep it basic in this introductory tutorial and stop here.

Evaluate the data

Next, we want to make sure that we've chosen the correct set of data to work with. Click the Evaluate button. In the Evaluate Output pane, we see all the data in the group:


Evaluate results.PNG

Save the tag

Click the Save Tag icon. This closes the Tag Editor and places our first [ForEach] tag in the table:


table with one tag.PNG

Create an [out] tag

Now it's time to place data subgroups into the individual cells. Click in the ID cell after the [ForEach] tag, and click the Tag Builder icon. Follow the same general procedure as you did with the [ForEach] tag, with a few changes:

  1. Click the Tags tab and click the [Out] Tag icon. (Note: the [out] tag is the default tag type, so typically this is already done for you.)

  2. Click the Select tab.

  3. In the Data Source pane, click the + sign next to the [ForEach] tag name that you created in step four – in this case, EmployeeList – to expand it.

  4. Drag the EmployeeID data subgroup from the EmployeeList into the Select Bar. Note: Be sure to drag and drop the correct EmployeeID data subgroup, as there are two listed in the Data Source Pane. Drag and drop the data subgroup from the EmployeeList, not from the main data source listed below it.

  5. Optional step: In the Nickname text box in the Attributes pane, type the name of the tag as you would like it to appear in the template. If you do not enter a nickname, AutoTag assigns a default name based on the information in the Select Bar. If you do enter a nickname, we strongly recommend you include square brackets around the text, so that anyone viewing the template can tell at a glance what is a tag and what is simply text.

  6. Evaluate the data by clicking the Evaluate button.

  7. Save the tag.

Create more [out] tags

Using the same procedures that you followed in the "Create an [out] tag section" above, create [out] tags for the three remaining cells.

Close the [ForEach] loop

Now that we have all our tags placed in the table, we must close the [ForEach] loop. Click the template just after the table and click the Tag Builder icon. Click the Tags tab, and click the [End ForEach] Tag icon. Click the Save Tag icon. Your template now has all the necessary tags in place:


table with all tags.PNG

Save and run the report

Save your report template using Word's Save command. Then, from the AutoTag Output button, click the desired report format icon. In this example, we chose to view the report as a DOCX file, and this is the result:

table output.PNG


Congratulations! You've now mastered the basics of creating tags. For help with complex tag creation and editing, please see our other tutorials.

  • Was this article helpful?