Search
Windows 7

Microsoft Visio 2010 : Linking External Data to Shapes (part 1) - Preparing the Data

Published 2 min readBy Programming4us Editorial Team

Shape Data fields are great in their own right, but if you already have a bunch of data somewhere else, the last thing you want to do is re-enter it. Luckily, Visio has a couple of ways to import data and stuff it into Shape Data fields:

  • The venerable Database Wizard, which is available in all editions of Visio. It has many powerful features, including the ability to change data in Visio and push it back to the database. On the downside, it is harder to use, it’s a bit complicated to understand, and data sources are harder to create.

  • Link Data, which was introduced in Visio 2007, and is available only in Pro and Premium. Hooking into a simple data source such as an Excel spreadsheet is super easy, and linking to shapes is fairly intuitive. You can link data from multiple sources to a single shape, too. But the data goes only one way: from source to Visio. You can’t push changes to Shape Data fields back to the database.

1. Preparing the Data

Before you start any data linking at all, prepare a data source in the form of a simple Excel spreadsheet. Continue with the light bulb theme by creating a list of bulbs with different characteristics.

Creating Data in Excel

1.

Start Microsoft Excel and create a new, blank worksheet.

2.

Create four column labels in the first row: ID, Model, Bulb Type, and Power (Watts).

3.

Enter the data shown in Figure 1 in columns B, C, and D. You don’t need to enter all of it, but do enter at least the first three or four rows. Column A is a calculation, so hold off on that for a moment.

Figure 1. Sample data for data linking in an Excel spreadsheet.


4.

You need unique IDs for each bulb. You could simply use the numbers 1–12, but the Database Wizard actually lets you choose records by picking an ID. If you make IDs that hint at the actual bulb characteristics, picking is easier than simply looking at numbers.

In cell A2, enter this formula:

=LEFT(B2,2) &“-“& LEFT(C2,3)&“-“&D2

This takes the first two characters in columns B and C, adds a dash between them, and finally appends the power to the end. So a 10-watt compact fluorescent from Flair gets an id of Fl-CF-10.

5.

Copy the formula in A2 to the rest of the cells in column A. Your spreadsheet should look something like that in Figure 1.

6.

Give the data range a name.

a. Select all the cells that contain values, including the column headers.

b. In the Name box in the upper left corner just below “Clipboard”, enter ModelTypePower, as shown in Figure 1. This will help the Database Wizard to find the data within the Excel file later.

7.

Save the spreadsheet as Light Bulb Data.xlsx for future use.