[Sigia-l] RE: VISIO - indexing wireframes

Todd Levy toddlevy at hotmail.com
Tue Nov 25 16:22:25 EST 2003


You can do this using VBA.

You'll need to first create a macro that exports the data to Excel and then 
present the data back in Visio by using an embedded Excel spreadsheet.

The first part is more complex, so here's a jump start...

1) Open your Visio File

2) Hit "Alt F11" to open the VBA editor

3) Open the Project Explorer (Ctrl - R) within the VBA editor

4) Right click the "Modules" folder and choose "Insert > Module"

5) Paste in this sub-routine that I just hacked together from various online 
examples

' -----------------------------------------
Public Sub OutputPageNamesToExcel()

  Dim appExcel As Excel.Application
  Dim xlBook As Excel.Workbook
  Dim xlSheet As Excel.Worksheet
  Dim intCurrExcelRow As Integer
  intCurrExcelRow = 1

  Dim objDocument As Visio.Document
  Set objDocument = Visio.ActiveDocument

  Dim intCurrPageIndex
  Dim objPage As Visio.Page
  Dim strCurrPageName As String

  Set appExcel = CreateObject("Excel.Application")
  appExcel.Application.Visible = True
  Set xlBook = appExcel.Workbooks.Add
  Set xlSheet = xlBook.Worksheets("Sheet1")

  xlSheet.Cells(intCurrExcelRow, 1).Value = "Page Number"
  xlSheet.Cells(intCurrExcelRow, 2).Value = "Page Name"
  intCurrExcelRow = intCurrExcelRow + 1

  For intCurrPageIndex = 1 To objDocument.Pages.Count
    Set objPage = objDocument.Pages.Item(intCurrPageIndex)
    strCurrPageName = objPage.Name
    xlSheet.Cells(intCurrExcelRow, 1).Value = intCurrPageIndex
    xlSheet.Cells(intCurrExcelRow, 2).Value = strCurrPageName
    intCurrExcelRow = intCurrExcelRow + 1
  Next intCurrPageIndex

End Sub
' -----------------------------------------

6) Go back to the Visio application

7) Choose "Tools > Macros > Module 1 > OutputPageNamesToExcel"

Viola!

You should now have an auto-generated Excel spreadheet of Visio page names 
with page numbers.

At this point you can (a) extend and customize the VBA macro to your liking 
and (b) insert the spreadhseet as an embedded object within Visio.

These links should help get you started...

<URL: 
http://msdn.microsoft.com/archive/en-us/dnarvisio/html/msofficedemo.asp >
<URL: http://www.google.com/search?q=Visio+VBA >

Hope this helps,
TL


>Message: 1
>Date: Mon, 24 Nov 2003 11:39:09 -0500 (EST)
>From: "Pradyot Rai" <prai at prady.com>
>To: <sigia-l at asis.org>
>Subject: [Sigia-l] VISIO - indexing wireframes
>
>Hi There,
>
>I am tring to look for some help on how can VISIO allow to index all the
>pages. I have created wireframe using Microsoft VISIO Professional
>2002(call it professional Hazard) and now want to add an Index page on
>the front page.
>
>I am quite familiar with the Microsoft Word, and it allows to do it with
>equal easy. Was wondering if Visio has anything like it.
>
>Thanks in advance for your reply.
>
>Pradyot Rai

_________________________________________________________________
online games and music with a high-speed Internet connection!  Prices start 
at less than $1 a day average.  https://broadband.msn.com (Prices may vary 
by service area.)




More information about the Sigia-l mailing list