hiding only some of the macros

L

Loui

I have created two collections of macros and 12 user forms
that are used by the macros. One of the two collections
of macros I want the users to be able to edit (change the
options from time to time), but I don't want them editing
the other ones. I know I can lock ALL of them with the
Properties Option, but can I lock some of them but NOT ALL
of them. Can I create a "sub-project" that has locked
macros and while the main project stays readable?

Loui
 
D

Doug Robbins - Word MVP

Hi Loui,

I suspect from your later post that you are using formfields in protected
documents, not userforms.

what sort of changes to the macros do you want the user to be able to make.
Sounds like a recipe for disaster to me.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
L

Loui

I know you can "hide" macros. I've seen it in other
offices. I go into the macros and the "edit" button is
not lit, but you can see the macro on the list and you can
run the macro. I want to know how that works!

Loui
 
M

Mark Tangard

Loui,

The Edit button is dimmed when the macro selected isn't
in the Normal template (or the template you have open,
if any). This isn't 'hiding' it per se; it just means
it can't be edited from that dialog under those conditions.
If the user can open the template containing the macros,
he/she can edit it if the project isn't protected.

If you want users to be able to run macros from the macro
dialog but not edit them, you must protect the project
that contains them (the whole project, can't do just a
portion). If you *don't* need them to be able to run
these macros from the macros dialog (for example, if you
can assign them to custom menu items or toolbar buttons),
you can declare them as Private procedures (just put the
word 'Private' before the 'Sub') and they won't appear
in the dialog and thus won't be editable or executable
from there, but can still be run from custom controls.

But I must strongly echo Doug's comment. Allowing users
who aren't thoroughly acquainted with macros to edit them
directly is a bit like giving a blowtorch to a 4-year-old.

If you need to let the user change a parameter, tbere are
cleaner ways to do that. One is to use an InputBox in
the code to prompt for the parameter, and once it is
supplied, store it in a text file (I like to use the
System.PrivateProfileString feature for this) from which
it will be retrieved the next time the macro is run and
offered as the default for the prompt. (This may sound
complicated and high-overhead but is truly trivial to
Word.) The text file can contain several parameters.
Tons of common programs use this method. To see examples,
take a look at any of the (likely dozens of) files in your
Windows folder whose names end with ".INI".

Post back with a sample parameter and relevant code from
your macro and I'll post an an example of how to arrange
this.

Slightly less elegant, and slightly more error-prone, is
to let the user edit that text file instead. The main
advantage here is that you could dispense with the prompt,
so the macro would always run with the parameter in the
text file, never asking the user to confirm or change it.

Please don't do it the way you're pondering.
 

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