problems with vba control names

I

iain

I am creating a document for which i need about 400
checkboxes (Microsoft Word 2000). I'm trying to name them
in such a way that I can keep track of them, but their
names keep changing by themselves. I have read that this
is an inherent property of this type of control, but I
was wondering in desperation if there is any way that
this can be averted? Is this error resolved in Word XP?
Please email suggestions ASAP
 
C

Cindy Meister -WordMVP-

Hi Iain,

Given the purpose - hide certain sections - I might approach
this differently.

1. You wouldn't need to use ActiveX controls - you could use
form field controls, or, if forms protection is too
restrictive, macrobuttonfields that display a checkbox.
(Take a look at how the FAX templates that MS supplies with
Word do their checkboxes)

This would mean you could use many more checkboxes in the
one document, as neither form fields nor macro buttons have
any where near the same overhead as ActiveX controls.

2. In any case, you should be able to wangle a way to use
only one macro for all the checkboxes. If you used a form
field, for example, and bookmarked the ranges, you could
make the formfield name include the bookmark name, so that
you could derive it. Or, if the checkboxes always stand in a
particular relationship to the ranges that are to be hidden,
use that positional relationship (next paragraph, for
example). Or if you use the styles route (described below),
you could format that checkbox with a "matching" style name.

3. You might also consider formatting each of these ranges
with a particular style(name) and changing the definition of
the style to use "hidden" font (or not). That might be
faster than working on a Range object.

Note: I have no idea of the meaning of the particular items
in the field code. I'm pretty sure the 1 has something to do
with the internal class of the control. No idea about /s.
Hi Cindy, thanks for your help. I've cut the number of
checkboxes down to 50 by cutting the document into 10,
and I've updated to Office SP3. It no longer renames the
controls, it doesn't even "create" them, by which I mean
that they remain unusable, with no properties assigned to
them, when the document is opened. They are there to be
seen but they aren't able to be clicked. It was working
fine (fully functional) before I closed the document. Do
you know any way to get around this?

Note: The purpose of the checkboxes in this document is
to hide certain sections of the document when we don't
need to print them, using the .range.font.hidden=true
property. In the procedure view in the visual basic
editor, there are many Private Sub procedures. Can these
be referenced and run by a form field checkbox, or would
I have to create simple macros to run them?

Also, I just clicked the "View Field Codes" button on one
of my toolbars, and it displays every checkbox like this:

{ CONTROL Forms.CheckBox.1 /s }

If I were to change the number 1 to the number I want the
checkbox to have, would that solve my problem, or does
the number 1 signify the type of checkbox? Just out of
curiousity, what does the "/s" do?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
M

Mark Tangard

That's definitely been my experience, though the controls' behavior
seemed to improve from horrific to substandard when I upgraded from
97 to 2000. I still would never use them on purpose. I've noticed
that, in the userforms newsgroup, folks seem to post about protected
forms and userforms with almost equal frequency but hardly anyone
ever posts there with an ActiveX question, even though logically
it should probably draw some interest. Maybe not many people ever
get the things to work at all in the first place....
 
C

Cindy Meister -WordMVP-

Hi Jeffrey,

My opinions - stated very politely for public consumption - can be found
here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnword2k2/
html/odc_activeX.asp
I was wondering. It has been my experience that the active x controls are
more of a pain than they are worth. You get more than a few of them on a
document and they start to act really weird. They seem to eat memory like
there's no tomorrow. Have you, (or do you) recommend that they be used at
all (I shy away from them myself)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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