Creating and Customizing Graphs in Word From LabVIEW

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Creating and Customizing Graphs in Microsoft Word Documents from LabVIEW

Publish Date: Oct 26, 2006

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
InsertObjectMicrosoft 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
1. Creating and Using Word Templates
2. Using Bookmarks
3. Comparison of Graph Properties Available in LabVIEW and Only in Word
4. Accessing Graph Properties Only in Word

1. 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.
1. Launch Microsoft Word.
2. Select FileNew and open the Templates dialog box.
3. Select the Template option from the Create New section, as shown in the following dialog box.
4. Click the OK button.

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.

2. 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.
1. Place the cursor in your Word template where you want the new bookmark to be. This location is where LabVIEW will insert the graph.
2. Select InsertBookmark to open the Bookmark dialog box.
3. Enter a bookmark name (for this example, Graph) and click the Add button.
Note Bookmark names cannot contain spaces or any special characters.
4. 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.
5. 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.
Refer to the LabVIEW Help for information about the Report Generation VIs.

3. 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

1/4

www.ni.com

Axis
Word Set Graph Scale VI
Axis type
Category

Format Axis
Patterns
Major Tick Mark

Series Axis

Minor Tick Mark

Value

Tick Mark Labels

Axis Configuration
Autoscale

Scale
Display Units

Min

Value (Y) Axis Scale

Max

Major Unit

Scale Type

Minor Unit

Linear

Alignment
Orientation

Logarithmic
Fonts
Word Set Graph Font VI
Axis Font
Font Style

Format Plot and Chart Area


Font
Background

Bold/Italic

Effects

Underline

Strikethrough

Size

Superscript

Color

Subscript

Plot and Chart Area


Word Insert Graph VI
Graph Title (string)

Chart Options
Legend

Graph Size (cluster)

Data Table

Row Headers
Format Legend
Patterns

Column Headers
Measurement System

Font

Has Legend

Placement
Word Set Graph Scale VI
Gridlines
Has Major Gridlines?

Format Data Series


Patterns
Line Style

Has Minor Gridlines?

Marker Color and Size

Major Gridlines Color?

X and Y Error Bars


Display

Minor Gridlines Color?

Error Amount
Shape
Data Labels
Options
Gap Depth
Gap Width
Chart Depth
Format Plot or Chart Area
Patterns
Border
Fill Effects
Gradient
Texture
Pattern
Picture

4. 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.

2/4

www.ni.com

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.

3/4

www.ni.com

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

4/4

www.ni.com

You might also like