Create Sno to the index sheet

Started by chathavardhan, August 23, 2012, 11:11:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chathavardhan

Hello all ,

Using the below program I have created a index sheet.

Sub TableOfContents()
     ' creates a shape for each page in the drawing on the first page of the drawing
     ' then add a dbl-clk GoTo to each shape so you can double click and go to that Page
     
    Dim PageObj   As Visio.Page
    Dim TOCEntry  As Visio.Shape
    Dim CellObj   As Visio.Cell
    Dim PosY      As Double
    Dim PageCnt   As Double
     
     ' ActiveDocument.Pages.Count will give the number of pages, but we are interested
     ' the number of foreground pages
    PageCnt = 0
    For Each PageObj In ActiveDocument.Pages
        If PageObj.Background = False Then PageCnt = PageCnt + 1
    Next
     
     ' loop through all the pages
    For Each PageObj In ActiveDocument.Pages
        If PageObj.Background = False Then ' Only foreground pages
             
             ' where to put the entry on the page?
            PosY = (PageCnt - PageObj.Index) / 4 + 1
             
             ' draw a rectangle for each page to hold the text
            Set TOCEntry = ActiveDocument.Pages(1).DrawRectangle(1, PosY, 4, PosY + 0.25)
             
             ' write the page name in the rectangle
            TOCEntry.Text = PageObj.Name
             
             ' add a link to point to the page to you can just go there with a Double Click
            Set CellObj = TOCEntry.CellsSRC(visSectionObject, visRowEvent, visEvtCellDblClick) 'Start
            CellObj.Formula = "GOTOPAGE(""" + PageObj.Name + """)"
             
        End If
    Next
     
     'Clean Up
    Set CellObj = Nothing
    Set TOCEntry = Nothing
    Set PageObj = Nothing
End Sub

Now I am trying to create a Sno for the table can any one help me with this.

Thanks in advance.

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

chathavardhan

Serial Number for the number of pages I have a different page I want serial number for that table.

Paul Herber

Your "table" is just a bunch of shapes arranged visually in that manner, it isn't a real table. If you group all the shapes then you will have a shape. That shape has an ID you can use.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

chathavardhan

I completely agree but I am trying to create similliar shapes with serial numbers in it using vba next to the shape which has already created can you please help if you have any questions feel free to ask.

Jumpy


Set TOCEntry2 = ActiveDocument.Pages(1).DrawRectangle(5, PosY, 8, PosY + 0.25)
' write ID in the rectangle
TOCEntry2.Text = PageObj.ID
'If it were a shape u could use shape.UniqueID


?