Word Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Word Hacks [Electronic resources] - نسخه متنی

Andrew Savikas

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 58 Keep the Macros Dialog Box Tidy

Reduce clutter in your Macros dialog box by
preventing it from displaying some of your macros.

When developing a macro,
it's often best to split the macro into several
small parts, each responsible for performing some part of the overall
action. This makes the macro easier to write, easier to debug,
andbest of alleasier to reuse.

The downside to this strategy is that the number of macros in the
Macros dialog box (ToolsMacroMacros) quickly
balloons, making it hard to find the one you need amid the clutter.
True, you can assign macros to toolbars or menu buttons [Hack #1], but
if you use the macros only occasionally, you may not want to clutter
up your toolbars or menus with them either.

Here are two things you can do to keep that dialog neat.


7.3.1 Name Macros Clearly and Consistently


If your Macros dialog box is full
of
macros with names like test,
fixer, and mymacro,
you'll have a much more difficult time finding what
you need than if you use descriptive names like
DeleteAllHyperlinks or
SetLandscapeMargins. Practically speaking, your
macro names can be as long as you want, so use the space.

Plus, if you use the above naming convention (starting each word in
the name with a capital letter) and assign the macro to a toolbar
button, Word will separate the words in the ToolTip that appears when
you hover the mouse over the button. For example, Figure 7-3 shows one of the macros used to write the
manuscript for this book.


Figure 7-3. When you use capital letters to start new words in a macro name, Word automatically inserts spaces between them in the ToolTip text


7.3.2 Hide Macros from the Macros Dialog Box


If you write a procedure that either requires an input
value to run or returns an output value when it finishes (or both),
the procedure will not appear in the Macros dialog box. From the Word
interface alone, there is no way for the macro to get the input it
needs or handle the output it provides. For that, you need additional
macro code.

For example, the following two procedures will not appear in the
Macros dialog box:

Sub ComplimentMe(sName as String)
MsgBox sName & " is a lovely name."
End Sub
Function OppositeDay(bInput as Boolean) As Boolean
OppositeDay = Not bInput
End Function

Thus, to keep a macro out of the Macros dialog box, you can trick it
into thinking it needs a value to run by using
an Optional argument:

Sub SuperSecretMacro(Optional bFakeInput As Boolean)
MsgBox "Curses, foiled again"
End Sub

Now the only way to run this macro is from another macro, as with the
following code:

Sub ShowSecretMacro( )
Call SuperSecretMacro
End Sub

Microsoft uses this particular technique extensively in the Office
Wizards to keep the code from appearing in the Macros dialog.


/ 162