Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indexing in Visio 1

Status
Not open for further replies.

howzatUK

IS-IT--Management
Oct 14, 2005
23
GB
Does anyone know how to create an automatic indexing page in visio, so that it will create a list of all the sheets in my document, including their name and number?

a visio novice
 
You can create this type of index manually, or possibly write your own script to do so, There is no function in visio that will do this automatically

rvnguy
"I know everything..I just can't remember it all
 
yes by my document is huge and creating an index is a very time consuming task, I was wondering If anyone on this site knew how I could create an index automatically?
 
In Visio object model look at the ThisDocument object. It has a Pages collection. Each item in the Pages collection has a Name property:
Code:
Dim p As Page
For Each p In ThisDocument.Pages
Debug.Print p.Name
Next p
This will get you started

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Hi thanks for that.

It feels like what I want to do may be possible then.

What shall I do with the code? where do I place it?

a greatfull novice
 

Put it in whatever event you want it to fire on. For instance if you want it to run everytime you add a new page to the doument it would go in the Document_PageAdded event.

To see a list of document events open your code window (ALT-F11), double click on ThisDocument in the Project Explorer (CTRL-R if it's not visible), select Document in the lefthand dropdown at the top of the code, then browse through the events in the righthand dropdown.

Or you could add a command button to one of your pages and use the CommandButton1_Click() event

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Cheers.

Ok i see now. So how would i get it to print to a specific shape/object?

 

You may need to look into the properties of various shapes in Object Browser, and Visio VBA Help. Most shapes have a Text property, settable in code. I have just put a square on page1 of my document, and replaced
Code:
Debug.Print p.Name
with
Code:
ThisDocument.Pages(1).Shapes("square").Text = ThisDocument.Pages(1).Shapes("square").Text & p.Name & vbCrLf
The list of pages comes up as text in the shape. You will of course need to clear the text in the square at the start of the routine.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thats great I now have it listing all the page numbers. However on each sheet i have a shape called title which contains some text, i would also like that printed next to the page numbers. I have tried this below, but it compiles errors. any ideas?

ThisDocument.Pages(3).Shapes("square").Text = ""

Dim p As Page
Dim t As ThisDocument.Pages("p").Shapes("Title").Text
For Each p In ThisDocument.Pages
ThisDocument.Pages(3).Shapes("square").Text = ThisDocument.Pages(3).Shapes("square").Text & p.Name & vbCrLf
Next p

End Sub
 
ok my above problem is solved, but now im feeling adventorous!

Can you tell me how i can automatically create a text box called title on every new page created?
 
It may be beyond the scope of the forum to give a full tutorial on Visio VBA, but one good way of exploring the object model is to use Tools|Macros|Record New Macro, run through the actions you want to code, stop the recording and then have a look (in the code window) under Modules|NewMacros. You can usually see what the code does and hack it from there.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
yes thank you for getting me this far, i have transfered the thread over to the VBA forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top