Can I convert a control's value to a function name in code?

  • Thread starter Thread starter Tony Vrolyk
  • Start date Start date
T

Tony Vrolyk

I use Word Automation a lot and when I setup these 'exports' as we call
them, I have to add a button to a form and the associated code. The form has
gotten too busy so I am trying a new approach.

I have created a table that stores the various function names. The table
store the function name, a friendly name, category etc. They are presented
to the user in a list box so they can choose which they want to run. Is
there a way in code to pull the selected value from the list box and run it
as a function?

Thanks
Tony
 
Tony,

I would be pretty certain it would be possible. Can you give some
detailed examples of what you want to happen in response to the
selection in the listbox?
 
I am not sure what else to say but I will try.

1. I have a table where I store data about these export funtions. There is a
field for the function name (as it would be called in code), a f riendly
name that is displayed to the user and other info that I use to orgnize and
query the list. For instance the functions are categorized based on where
the user is in the application.

2. On a form I have a list box that displays export functions to the user
using their friendly names. The actual function name being column 1, bound
and hidden.

3. The user would choose from the list of friendly names then click Run.

4. The code behind the Run button would take the value of the list box
(which is the function name) and run that function.

It is number 4 where I am not sure what to do. Eval() is close but it is
only usefull for returning a value. In this case I am executing a Word
Automation task

Does that clarify it more? Let me know if you need more details
Tony
 
Tony,

Sorry for lack of clarity. I was really asking for examples of function
names and details of functions themselves, etc.

But anyway, now I get the drift of what you mean. :-)

Theree may be a more elegant way of directly using the listbox's value
to reference the function name, but I don't know how to do this. The
simple solution is like this, I suppose...

Select Case Me.ListboxName
Case "FirstFunction"
Call FirstFunction (arg1, arg2...)
Case "SecondFunction"
Call SecondFunction
...
End select
 
Yea that is what I thought of and am using in another application but I was
trying to avoid having to add the code each time I add a new function. I was
hoping to be able to just add it to the table and be done with it.

Thanks for your suggestion. If anyone else following this thread has an idea
I would love to hear it. Otherwise I'll keep looking around and see what I
find.

Tony
 
Back
Top