Visio Guy

Visio Discussions => Programming & Code => Topic started by: Dean on February 12, 2016, 09:44:44 AM

Title: Unique ID's are NOT matching up
Post by: Dean on February 12, 2016, 09:44:44 AM
I dragged and dropped shapes into a blank Visio page. They auto ID into the following which I check through the "shape name" tab:
Quote1
24
47
51
48

(as a side discussion can anyone explain why this is not serialised, it seems quasi random to me)

I then write and execute the following macro:

Public Sub GetIDs_Example()

    Dim vsoSelection As Visio.Selection
    Dim lngShapeIDs() As Long
    Dim lngShapeID As Long
     
    ActiveWindow.DeselectAll
    ActiveWindow.SelectAll
     
    Set vsoSelection = ActiveWindow.Selection
     
    Call vsoSelection.GetIDs(lngShapeIDs)
     
    For lngShapeID = LBound(lngShapeIDs) To UBound(lngShapeIDs)
        Debug.Print lngShapeID
    Next

End Sub


The output of the macro is printed in the immediate window command prompt as the following:
Quote
0
1
2
3
4

How come the ID numbers are not the same???
Title: Re: Unique ID's are NOT matching up
Post by: Surrogate on February 12, 2016, 10:09:16 AM
Debug.Print lngShapeID you just iterate array, and print count !
For i = 1 To vsoSelection.Count
        Debug.Print vsoSelection(i).ID
     Next


PS it is NOT Unique ID (https://msdn.microsoft.com/en-us/library/office/ff767736.aspx) like as "{2287DC42-B167-11CE-88E9-0020AFDDD917}", it is just ID (https://msdn.microsoft.com/EN-US/library/office/ff767467.aspx)
Title: Re: Unique ID's are NOT matching up
Post by: Dean on February 12, 2016, 10:26:08 AM
Oh I see.

How do I display an ID of a shape after clicking it?

Title: Re: Unique ID's are NOT matching up
Post by: Surrogate on February 12, 2016, 11:38:23 AM
you mean just once clicking or double clicking ?
Title: Re: Unique ID's are NOT matching up
Post by: Dean on February 12, 2016, 11:40:28 AM
Once
Title: Re: Unique ID's are NOT matching up
Post by: Surrogate on February 12, 2016, 11:57:42 AM
use Google Translateā„¢ for read this thread in Russian forum (https://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.cyberforum.ru%2Fvba%2Fthread1429395.html)
Title: Re: Unique ID's are NOT matching up
Post by: Dean on February 12, 2016, 04:56:58 PM
Spasiba :-) Thanks, Ill try it later and let you know