Create a drop-down list in VBA

Started by tyrael, June 22, 2012, 02:41:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tyrael

Hi,

I want to create a drop-down list in VBA to let the user select a value which correspond to a layer.
I explain :
I created a group made of multiple shapes linked to a database to have all my value added automatically for all my applications (cf the shape in the attachement file).
So I created a VBA code to create all my shapes, add the primary key value, and then the code create a layer in which there is all my group, and another layer in which there is just the shape with the dates (cf the shape).
I also made a shape when you double-click on it, you can type a layer name and it changes its visibility to hide or show what the user want to have a clear view of the different app.
But to made something cleaner, I want to create a drop-down list instead of leting the user type the layer name. So the user will have to choose in the list which layer he wants to hide or show.

I found in insert/Control things that could help, but didn't success with them.

Also, I want to create a box or a calendar, where the user can choose a date and then all the application with a date under this date will disappear or two dates, to show the map of my applications at a time T.
If you have idea how to do this ?

I use Visio Standard 2007

Thank in advance for your tips and ideas
And excuse me for my potential mistake, english isn't my native language
Tyrael

Jumpy

Quote from: tyrael on June 22, 2012, 02:41:19 PM
But to made something cleaner, I want to create a drop-down list instead of leting the user type the layer name. So the user will have to choose in the list which layer he wants to hide or show.

Where do you want that DropDown list?
- In a Windows Form?
- In a ComboBox-Control or sth. like that on the page?
- In a shape (for example in the ShapeData?)
- In the ShapedData of the page?

tyrael

Ty for the reply

In a Windows Form.
The user double click on a shape which will be a button, a windows open, select a layer, click Ok, and the visibility of this layer change.


aledlund


tyrael

Sorry for my late reply, a bit busy with my job

Ty Al for the link

It's really interesting but I didn't find something useable for my problem  :-\

I want to open a Windows Form with a drop down list of my different layer when the user double click on a specific shape
This will change the value of the visibility of my layer (this point isn't really a problem, if I can have the user-choice)

This will be more user-friendly for a non-Visio-user, because he/she will not have to find the layer properties.

And my second question is about the date. As you can see in my attach picture, my shape have to date in it (from a database), and I want the user be able to show a instant T of the map be typing a date in a calendar or a box to show/hide functional applications.

I hope this new information could help you to find some solutions
Thank in advance for your reply

Tyrael


aledlund

It's a relatively simple piece of code, but the weekend will be spent focusing on some family issues. I'll see if I can post something by late monday.
al

tyrael

Thank you very much for your help
Have a nice weekend

aledlund

the attached drawing has three shapes on individual layers. The shapes are configured so that if you double-click them they will open a form to allow turning layers on and off and selecting dates. If you press the sel button next to the date fields on the selection form, it will open a calendar control.
al

tyrael

Thank you again Al !
It works really well, there is all I need in this drawing (drop-down list and date/Calendar)

But I have some difficulties to understand all your code with the userform

Do you know a tutorial or a website to help me to understand all the code you used ?
I would like to be able to do it myself and so understand all you did to be able to recreate something similar

Tyrael

aledlund

It's really (no pun intended) pretty basic. The forms are really being used as dialogs (i.e. when we call them from other places in the code, nothing else happens until we close/hide them). Since we never create a 'new' copy of them they are always available to be accessed and we can set them up and then read them when we need them. My experience when I go to learn something new is I generally end up checking several places and get a couple of different people explaining it (until I find one that make sense to me).

The Visio materials of course can be found over here
http://msdn.microsoft.com/en-us/library/aa245244(v=office.10).aspx
The only thing that might be new is how we use 'CALLTHIS' to get to the doubleclick action. I prefer using CALLTHIS because of the flexibility to add operands to the process while passing the information on which shape was acted upon.

The calendar control is the one that Office 2007 installed, but obviously works fine.
http://msdn.microsoft.com/en-us/library/aa188210(v=office.10).aspx

al

tyrael

I modified your code to see what happened and I think I partially understood it.
I also checked on differents places to understand some terms I don't understand (such as the ByVal, property, Me. , selOk ...) - (Yep, I'm a novice in VBA, I pratice for 3 weeks and just the basic (database link in vba, create shape/Master in vba, link shape, select/for/if))

So I cut your userform into 2 differents ones to add each one to a different shape.
I still have some problems with the code, but it's a matter of time and practice I think
(If I have a new unsolvable problem, I will ask)

So, thank you very much for your help and your tips

Tyrael

tyrael

#11
I come back, just to ask a little question.
As I said, I cut your userform into two forms keeping your code.
But how can I keep the value of "strResult" ? (the date when I close the userform)
Because I want to use it and store it.

I don't really understand all the options of the private, public etc... function
And I can't access for example a shape.text before click on Ok to store the date and to run a maccro which will compare this date with the date store in my shapes to hide them if they're older than the date.

Thank you in advance

Tyrael


EDIT :
I think I found it ?
I added  :

Private m_shape As Visio.Shape

Private Property Get visShape() As Visio.Shape
Set visShape = m_shape
End Property

Public Property Set visShape(ByVal val As Visio.Shape)
Set m_shape = val
End Property


And then in the OpenSelectForm, I add a formula to change the text of a shape.
And it works, but can I run a maccro with this technic ?

aledlund

I'd suggest we take this one off-line. I'm (edlund60014) over onyahoo dot com.
al

tyrael

Email send
Hope I didn't made a mistake in the adress

Thank you

Tyrael