Less Hardcoded text

M

mikeFin

Hello !

I have a problem, I have to much Hardcoded parts as VBA Code.

For example I would like to have a variable number of radio-buttons in a
form. (This form appear after I double click on a shape).
I manage to have a variable amount of radio-buttons by making the one I
don't need invisible.

I would like to initialize my form with somthing like this:

- - -
Private Sub UserForm_Initialize()

For i=1 To numbOfProj

if ActiveDocument.Pages(1).Shapes("ThePage").Cells("User.Proj" & i &
").ResultStr(0) = True Then
Me.radioBtn & k & .Value = True
EndIf

Next

End Sub
- - -

The Problem is that
Me.radioBtn & k & .Value = True
is not a correct syntax, so it doesn't works.

Is there a way to make this work ?

Thanks in advance!
 
J

JuneTheSecond

Hi, mikeFin.

Option buttons on the page are also the shapes.
Shape.Object property might be useful to handle
controls.

Sub test()
Dim shp As Visio.Shape
For Each shp In ActivePage.Shapes
If shp.Name Like "OptionButton*" Then
shp.Object.Value = True
End If
Next
End Sub
 
M

mikeFin

Thanks for the answer.
I guess this doesn't work, if the Button is in a Form that pops-up (I mean a
Button not in a drawing). I created the Button in VBA->Forms.
 

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