bind a combo box item with a shape's custom properties

S

Sueprnaut

Hi,
I have a problem with combo boxes in Visio 2003. My question is how to bind
the combo box item with the shape's custom properties. Is this possible? What
is the code that I have to write in the Visual Basic Editor?
 
A

Al Edlund

The code should be fairly straight forward and would probably be based on
the shape selected event.
Determine shape selected
get a count of rows in the custom properties section of the shape sheet
iterate through the custom propeties and fill the control with what you
want (name, property value, etc)

There are examples in the visio sdk available for download on msdn of how to
read the custom properties..
al
 
S

Sueprnaut

Thanks for your reply.
I already created custom properties for a shape. I inserted a combo box
object and add some items:

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
ComboBox1.AddItem "hardware devices"
ComboBox1.AddItem "operating system"
ComboBox1.AddItem "database"
ComboBox1.AddItem "applications"
ComboBox1.Value = " -- select --"
End Sub

But now I don't know how to bind them with shape's custom properties. I want
when I click on a combo box item to view the custom properties of this shape.

Private Sub ComboBox1_Change()
Select Case ComboBox1
Case "hardware devices"
.....
Case "operating system"
.....
Case "database"
.....
Case "applications"
.....
End Select
End Sub

Is this possible to realize? Is there class or method which can make this.
 
S

Sueprnaut

Thanks for your reply.
I already created custom properties for a shape. I also insert a combo box
and add to it some items:

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
ComboBox1.AddItem "hardware devices"
ComboBox1.AddItem "operating system"
ComboBox1.AddItem "database"
ComboBox1.AddItem "applications"
ComboBox1.Value = " -- select --"
End Sub

I don't know how to bind one of these items to the shape's custom
properties. I want when I click on a item to view the shape's properties. I
try with Select Case:

Private Sub ComboBox1_Change()
Select Case ComboBox1
Case "hardware devices"
....
Case "operating system"
...
Case "database"
....
Case "applications"
....
End Select
End Sub

Is there any method or class to make this? Is this possible in general and
am I on the right way?
 
A

Al Edlund

calling something like this should get you started. the custom property code
is in the visio sdk.
al



' make sure something is selected
If 0 < visWin.Selection.Count Then

' get the shape (make sure index is correct for language variant being used

vsojShape = visWin.Selection.Item(0)

' test to let them know your looking at the correct object

msgbox cstr(objShape.Name)

' ReadANamedCustomProperty
ReadANamedCustomProperty(vsoShape As Visio.shape, _
strCellName As String, _
Optional blnIsLocalName As Boolean = False)

end if
 
S

Sueprnaut

Thanks for the help,
I managed to read a single custom property of a shape, but my problem
requires when I click on an item from drop down list of the combo box to view
the visio custom properties window of the shape with all its properties - not
in message box. Is there a way?
I will be greatful to you if you have any ideas about this.
 
A

Al Edlund

I'd make the code snippet into a subroutine and input the name of the custom
property. I would then call the subroutine from the case statement with the
appropriate property name. If you want all of the properties you can get a
count of rows for the section and then iterate through all of them.
al
 
S

Sueprnaut

Can I show up the whole shape's custom properties window? Because this
properties are linked with MS Access database and I want to make changes on
them.
 
S

Sueprnaut

After all I managed to show up the custom properies window of selected shape.
But first I want to show up the properties of the shape that I indicate in
the code (visShape) - not the selected shape from the Visio draw page. Then
when I close the custom properties it gives me error - Run-time error
'-20324669555(86db03f5). I don't know where I'm wrong. Please, give me some
hints or tell me what I have to add or change in the code.
Here is the code:

Private Sub ComboBox1_Change()

Dim visShape As Visio.Shape
Set visShape = ActivePage.Shapes.Item(4)

Select Case ComboBox1
Case "hardware devices"
visShape.Application.DoCmd (1312)
Case ...
End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top