Creating and Customizing Graphs in Microsoft Word Documents from LabVIEW
Overview
The LabVIEW Report Generation Toolkit for Microsoft Office includes VIs to create and customize graphs in Microsoft Word from LabVIEW. With the Word Insert Graph VI, you can programmatically insert and populate a graph in a Word document, and you can customize the graph with the Word Graphs and Pictures VIs.
Note The LabVIEW Report Generation Toolkit VIs do not offer access to all exposed ActiveX properties and methods for graphs available in Word. If you need to customize graphs beyond the options in the LabVIEW Report Generation Toolkit VIs, create a Word template, insert a graph, and customize the graph manually in Word. To insert a graph in a Word template, select Insert»Object»Microsoft Graph Chart. Then use the Word Update Graph VI to populate the customized graph with data from LabVIEW.
This document explains how to create and use Word templates, use bookmarks, and access the graph properties from LabVIEW and Word.
Table of Contents
Creating and Using Word Templates
You can create custom report templates in Word to ensure a consistent appearance across multiple reports. Use templates to define page size, text formatting, and other aspects of report appearance. Complete the following steps to create a template in Word.
- Launch Microsoft Word.
- Select File»New and open the Templates dialog box.
- Select the Template option from the Create New section, as shown in the following dialog box.
- Click the OK button.

[+] Enlarge Image
The template looks exactly like a Word document, but it has .dot extension instead of a .doc extension. You now can add standard elements to the report template, including a company header and the report date. You also need to identify where in the document you want LabVIEW to insert the graph, which is described in the next section.
Using Bookmarks
A bookmark in a Word document or template marks a specific location in that document. In this example, you use a bookmark to identify the location of the graph you will insert from LabVIEW. Complete the following steps to define a bookmark in your Word template.
- Place the cursor in your Word template where you want the new bookmark to be. This location is where LabVIEW will insert the graph.
- Select Insert»Bookmark to open the Bookmark dialog box.
- Enter a bookmark name (for this example, Graph) and click the Add button.
Note Bookmark names cannot contain spaces or any special characters. - In LabVIEW, use the Word Insert Graph VI to insert a new graph in the current template. Use the bookmark name input to specify where LabVIEW should insert the graph in the Word template. This VI supports all the graph types provided by Microsoft Graph.
- Use the following VIs to modify the scale and to change color and font attributes: Word Set Graph Scale VI, Word Set Graph Colors VI, and Word Set Graph Font VI. Use the Word Format Picture VI to set the graph size or color.
Comparison of Graph Properties Available in LabVIEW and Only in Word
You can customize several areas of a graph, including the chart type, axis, font, plot and chart area, chart options, and data series. You can customize some properties programmatically from LabVIEW, but you can customize some properties only in Word. The following table compares graph properties available from LabVIEW VIs and graph properties available only in Word. Refer to the Accessing Graph Properties Only in Word section for information about accessing the properties available only in Word.
| Graph Properties Available from LabVIEW | Graph Properties Available Only in Word |
| Axis | |
Word Set Graph Scale VI
|
Format Axis
|
| Fonts | |
Word Set Graph Font VI
|
Format Plot and Chart Area
|
| Plot and Chart Area | |
Word Insert Graph VI
Word Set Graph Scale VI
|
Chart Options
Format Legend
Format Data Series
Format Plot or Chart Area
|
Accessing Graph Properties Only in Word
The following sections explain how to customize properties in Word.
Chart Type
To change the chart type, select the graph by double-clicking anywhere on the graph and then right-click the graph and select Chart Type. This examples uses the XY (Scatter) Plot with data points connected by smoothed lines.
Axis Properties
To format an axis, right-click the x- or y-axis and select Format Axis to open the Format Axis dialog box, as shown below.

Plot Properties
To format a plot, right-click the plot area and select Format Plot Area, as shown in the figure below.

Chart Area Properties
To format the chart area, right-click anywhere on the graph outside the plot area and select Format Chart Area, as shown in the figure below.

Data Series Properties
Right-click a plot and select Format Data Series to open the Format Data Series dialog box, shown in the figure below. Right-click a data point and select Format Data Series to access additional formatting options for that data point, including the x and y error bars.

Legend Properties
Right-click a legend and select Format Legend to set legend properties.
Related Links:
LabVIEW Report Generation Toolkit for Microsoft Office User Guide
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
