Radio buttons on Visio page

A

AussieJim

Hi,

I'm trying to use Option Buttons on a Visio 2007 page. I inserted 4 option
buttons onto the page (Insert Control from Developer Toolbar, then selected
Microsoft Forms 2.0 OptionButton). However, I can't find a way to group them,
such that checking one will uncheck the others. They don’t default to the
same group. I’ve set the GroupName property for each Option Button to the
same name, but still they won’t group.

I might be missing something really obvious here, but I'm pulling my hair
out trying to find it. Can anyone tell me how this is done?

Thanks!

-jim.
 
A

AlEdlund

did you insert a frame? In my experience option buttons often get their
behavior from the frame they live in.
al
 
A

AussieJim

I did (but I don't know what I'm doing). I couldn't find a way to associate
the Option Buttons with the Frame. Dragging on top didn't help. Selecting the
frame then inserting new Option Buttons didn't do it. Grouping shapes didn't
help. And setting the GroupName property for each Option Button to the name
of the Frame didn't work. I'm sure I'm missing something simple, just don't
know what it is...
 
A

AlEdlund

The option buttons aren't associating with the frame on the document. They
do associate with a frame if I create a form inside the drawing and call it
from the document with a command button. SWAG the controls are forms based
and some of them don't recognize the drawing surface as a "form".
al
 
A

AussieJim

Thanks for looking at this, Al.

I guess what i really want to know, is can I add 3 option buttons to a Visio
drawing, and use them to trigger VBA code associated with the drawing. I have
a Visio flow diagram which includes decision and process boxes which include
time of day in their text. I've written all the code to change the text to
show the times in different time zones, and I'd like to select the time zone
to display using radio buttons. Are option buttons not an option?

-jim.
 
A

AlEdlund

what I do is (since your code is written) is just have a command button on
the drawing pull up a form with the controls that I need. It's a very simple
vba function.
al
 
C

Chris Roth [Visio MVP]

Allright Mate,

You can put the option buttons on a frame in the Visio page. You have to
double-click the frame control first to activate the surface.

At that point, you can add an option button, whereupon you'll have no
idea how to hook code up to the click event of the radio button. THAT is
REALLY WEIRD.

However, I've found a workaround. Start with this setup, then copy the code:

1 Frame control on the Visio page
2 OptionButtons in the Frame (names: OptionButton1, OptionButton2)

Now, paste this code in your ThisDocument class:

-----------------------------

Private WithEvents m_op1 As OptionButton
Private WithEvents m_op2 As OptionButton

Private Sub Document_RunModeEntered(ByVal doc As IVDocument)
Set m_op1 = Me.Frame1.Controls(0)
Set m_op2 = Me.Frame1.Controls(1)
End Sub

Private Sub m_op1_Click()
Debug.Print "OptionButton1.Click"
End Sub

Private Sub m_op2_Click()
Debug.Print "OptionButton2.Click"
End Sub

-----------------------------

What I've done is created two OptionButton variables (m_op1, m_op2),
with events attached. I then manually link the controls to these
variables when the Visio document is opened (or a copy is opened)

This is the code in Document_RunModeEntered. A bit laborious, but it works!


--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
A

AlEdlund

neat,
thanks Chris. I didn't even think of the withevents (aaadd - age accelerated
attention deficit disorder).
al
 

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