Dynamically Changing VBA Editor

V

victorsc.cheng

Hi guys,

I'm new to programming with MS Word, I was wondering if anybody could
give me a hand. Here's what I'm trying to do:

I'm trying to create a tool such that when a user activates it, a
control text box and command button will appear. The user will then
type text within the text box and when they click the button that was
created when the user activated the tool, this text will be used to do
certain things and so on.... The user would have the choice of creating
as many copies of these textbox and buttons and deleting them as they
desire.

My biggest problem right now is trying to define the events of a
textbox and commandbutton that was generated at run time by the user.
Generally, events are specified by the developer but now, the
textbox/buttons don't even exist until the user creates it. I read an
article on msdn.com (http://support.microsoft.com/?kbid=246299) and
they suggest dynamically generating events at runtime, but I worry that
this will cause overall instability in my program. Furthermore, what
would I do if the user decides to remove a textbox and button? How will
I remove its corresponding events as well?

Please correct me if any of my terminolgy is incorrect. I'm still quite
new to this field, any comments and suggestions are greatly
appreicated! Thanks a lot!

Victor
 
H

Howard Kaikow

Hi guys,

I'm new to programming with MS Word, I was wondering if anybody could
give me a hand. Here's what I'm trying to do:

I'm trying to create a tool such that when a user activates it, a
control text box and command button will appear. The user will then
type text within the text box and when they click the button that was
created when the user activated the tool, this text will be used to do
certain things and so on.... The user would have the choice of creating
as many copies of these textbox and buttons and deleting them as they
desire.

My biggest problem right now is trying to define the events of a
textbox and commandbutton that was generated at run time by the user.
Generally, events are specified by the developer but now, the
textbox/buttons don't even exist until the user creates it. I read an
article on msdn.com (http://support.microsoft.com/?kbid=246299) and
they suggest dynamically generating events at runtime, but I worry that
this will cause overall instability in my program. Furthermore, what
would I do if the user decides to remove a textbox and button? How will
I remove its corresponding events as well?

Please correct me if any of my terminolgy is incorrect. I'm still quite
new to this field, any comments and suggestions are greatly
appreicated! Thanks a lot!

The KB article should lead you in a possible direction, but you are entering
an area which really should be entered only by experienced programmers.

Also, auntie virus software may very well complain about such dynamic
additions/deletions of code.

I expect that you could design the code to handle adding/deleting controls,
but this is very advanced programming.
 
V

victorsc.cheng

Thanks for your help Howard. I am still trying to figure ways avoiding
operations like this. In any case, would you happen to know any sites
or references I could use to learn more about adding/deleting controls?
Thanks again.
 

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