Exporting Data to Excel
The Cane Factory (Milling) example model provided with Sugars has an embedded Excel spread-
sheet as an example. You can copy the VBA code from this example into your own model and
then revise the code to select the Sugars data that you want exported from your model into the
spreadsheet. There is code for both an embedded spreadsheet and an external spreadsheet run-
ning in Excel separate from Visio/Sugars. Also included is VBA code to fix page names to make
the universal page name the same as the local page name in your model. All screen images in the
following text are using Visio 2002; however, the images for Visio 2003 are similar.
To create the embedded spreadsheet in your model, open your model and select <In-
sert><Object...> from the Visio menu (see below).
Scroll down to find Microsoft Office Excel Worksheet. Select the "Create New" radio button op-
tion and then click on Ok.
Page 1 of 5
Position the spreadsheet where you would like to see it on the page. Click outside of the newly
inserted spreadsheet to go back to Visio and then click on the spreadsheet object again to get the
normal Visio green handles around it. Then from Visio, select <Window><Show ShapeSheet>
and in the title bar of the ShapeSheet for the spreadsheet object, look for the Sheet number and
write it down (see below). The sheet number will be used in the VBA code to send custom prop-
erty data to the spreadsheet object. Note that you can rename the sheet number if you would like
to give it a more recognizable name (from Visio menu use: <Format><Special>).
Next, press the "Alt-F11" keys to open the VBA editor. Under <Tools><References...> be sure
the "Microsoft Excel 11.0 Object Library" is selected (see below).
Page 2 of 5
Now, start another instance of Visio by double clicking on the Visio icon on your desktop. Once
the 2nd instance of Visio is running, open the Cane Factory (Milling) example that is provided
with Sugars in the “C:\Program File