Author Topic: Create shape name with function/macro  (Read 511 times)

0 Members and 1 Guest are viewing this topic.

breital

  • Newbie
  • *
  • Posts: 7
Create shape name with function/macro
« on: February 06, 2018, 02:02:04 AM »
HEY guys,

I'd like to name a shape (in developer ribbon) with an individual letter combination and the number of the page it is linked to.

So e.g.: if the shape is linked to another shape at page 30 of foregrounds, its name should be A30.
Need your brains  :D
I don't know enough vba codes or orders to get the solution by myself  :-[

Hope it is easier for you!

Surrogate

  • Hero Member
  • *****
  • Posts: 854
    • ShapeSheet™ Knowledge Base
Re: Create shape name with function/macro
« Reply #1 on: February 06, 2018, 02:09:43 AM »
Hi !

what you mean as linked page ? Hyperlink sub-address to some page ?
« Last Edit: February 06, 2018, 02:26:20 AM by Surrogate »

breital

  • Newbie
  • *
  • Posts: 7
Re: Create shape name with function/macro
« Reply #2 on: February 14, 2018, 04:47:49 AM »
Hello Surrogate,

yes, exactly. A hyperlink with subadress to another page :)
I'm sure this must be possible anyway, but don't have the experience in VBA with Visio :/

Surrogate

  • Hero Member
  • *****
  • Posts: 854
    • ShapeSheet™ Knowledge Base
Re: Create shape name with function/macro
« Reply #3 on: February 14, 2018, 08:43:00 AM »
Please try this code !
Code: [Select]
Sub For_Breital()
Dim shp As Shape, sa As String, dp As Integer
For Each shp In ActivePage.Shapes
' check is shape have hyperlinks
If shp.SectionExists(visSectionHyperlink, visExistsAnywhere) Then
' check is shape's hyperlink have sub-address
    If Len(shp.Hyperlinks(0).SubAddress) > 0 Then
' check is sub-address have shape's name
        If InStr(shp.Hyperlinks(0).SubAddress, "/") > 0 Then
' split pagename in sub-address
            sa = Left(shp.Hyperlinks(0).SubAddress, InStr(shp.Hyperlinks(0).SubAddress, "/") - 1)
        Else
            sa = shp.Hyperlinks(0).SubAddress
        End If
' rename shape
    shp.Name = sa
    End If
End If
Next
End Sub