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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Hyperlink from Custom Property

Status
Not open for further replies.

EagleWebGuy

Technical User
Oct 29, 2002
1
US
I have a flowchart that represents a Web site map. Each shape has a Custom Property called URL, the value of which is (not surprisingly) its URL. I am trying to write a simple VB Macro that -- for each shape in the active page -- creates a Hyperlink whose value comes from the custom property "URL."

I know this must be straightforward, but my VB skills are rather lacking. I am also open to other solutions. Any help would be much appreciated.
 
Hi there,
This code should work fine, but you will have to add some error traping.
*******************************************************
Public Sub GetShape()
'this is rough snippet based on the help file examples
'to run this code make sure you have some shapes on the page with URL property
'copy and paste this code into your document (ThisDocument icon in the project window)

Dim I As Integer, iShapeCount As Integer
Dim shpsObj As Visio.Shapes

Set shpsObj = Visio.Application.ActivePage.Shapes

'get number of shapes on the page
iShapeCount = shpsObj.Count

'loop through all shapes
If iShapeCount > 0 Then
For I = 1 To iShapeCount
Call SetLink(shpsObj.Item(I))
Next I
Else
MsgBox " No Shapes On Page"
End If

End Sub
Sub SetLink(shpobj_arg As Visio.Shape)

Dim shpobj As Visio.Shape
Dim hlinkobj As Visio.Hyperlink
Dim celObj As Visio.Cell

Set shpobj = shpobj_arg

Set hlinkobj = shpobj.AddHyperlink

'get value of the custom property url
Set celObj = shpobj.Cells("Prop.URL")

'set hyperlink to the custom property url value
hlinkobj.Address = celObj.ResultStr(Visio.visNone)

End Sub
************************************************************
Dmitry

learn visio at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top