《Excel 2013 Power Programming with VBA》 试译样文

source:

What Makes a Good Utility?
An Excel utility, of course, should ultimately make your job easier or more efficient. But if you’re
developing utilities for other users, what makes an Excel utility valuable? I’ve put together a list of
elements that are common to good utilities:
➤ It adds something to Excel. This addition could be a new feature, a way to combine existing
features, or just a way to make an existing feature easier to use.
➤ It’s general in nature. Ideally, a utility should be useful under a wide variety of conditions.
Of course, writing a general-purpose utility is more difficult than it is to write one that works
in a highly defined environment.
➤ It’s flexible. The best utilities provide many options to handle various situations.
➤ It looks, works, and feels like an Excel command. Although adding your own special
touch to utilities is tempting, other users will find them easier to use if they look and act like
familiar Excel commands and dialog boxes.
➤ It provides help for the user when needed. In other words, the utility should have documentation
that’s thorough and accessible.
➤ It traps errors. An end user should never see a VBA error message. Any error messages that
appear should be ones that you write.
➤ Users can undo its effects. Users who don’t like the result caused by your utility should be
able to reverse their path.


Text Tools: The Anatomy of a Utility
In this section, I describe an Excel utility that I developed and use frequently. It’s also part of my
Power Utility Pak add-in. The Text Tools utility enables the user to manipulate text in a selected range
of cells. Specifically, this utility enables the user to do the following:
➤ Change the case of the text (uppercase, lowercase, proper case, sentence case, or toggle
case).
➤ Add characters to the text (at the beginning, at the end, or at a specific character position).
➤ Remove characters from the text (from the beginning, from the end, or from a specific position
within the string).
➤ Remove spaces from the text (either all spaces or excess spaces).
➤ Delete characters from the text (nonprinting characters, alphabetic characters, non-numeric
characters, nonalphabetic characters, or numeric characters).


Part IV: Advanced Programming Techniques

Figure 14-1 shows the Text Tools Utility dialog box.

Figure 14-1: Use the Text Tools utility to change the case of selected text.

The Text Tools utility is available on the book’s website. It’s a stand-alone version of the
tool included with the Power Utility Pak. The file, named text tools.xlam, is a standard
Excel add-in. When installed, it adds a new command to the Ribbon: Home➜Utilities➜
Text Tools. The VBA project isn’t protected with a password, so you can examine the
code to see how it works or make changes to better suit your needs.


优秀的实用程序都具备哪些特性?

毫无疑问,一款 Excel实用程序(实用工具,实用程序或者实用工具,全篇根据上下文统一名称,本翻译中暂定为实用程序)的终极目标就是要让您更加方便或高效的进行共走。但是假如是您来为其他用户来开发实用程序,您所开发的 Excel实用程序的价值体现在哪里呢?这里我列出了一些优秀实用程序普遍具备的特性:

增强了 Excel的功能。这种增强可以一种新功能(组合现有功能的或者简化现有功能的使用)

通用。理想情况下,一款实用程序应该可以在各种各样的广泛条件下派上用场。当然,编写一款通用用途的实用程序要比编写一款高度界定使用环境的实用程序要难很多。

灵活性。最优秀的工具能够提供许多选项来处理各种场景需求。

外观类似 Excel命令。虽然为实用程序添加您自定义的按钮非常吸引人,但是如果实用程序的外观与 Excel命令和对话框类似,其他的用户将会觉得它们更容易使用。

根据需要为用户提供帮助。换言之,优秀的实用程序应该能够提供通俗易懂的帮助文档。

错误提示。不应让最终用户看到任何 VBA错误消息。显示的任何错误消息都应该是您编写的。

用户可以撤销效果。如果用户不喜欢您的实用程序产生的效果,用户应该可以还原其操作。

.

文本工具:实用程序解析

 

----注释 texttools如果作为 UI建议不翻译,如果翻译也在正文中“文本工具”体现本译文中统一不译处理。--------------------

 

在本节中,我将介绍一款我开发的并且经常实用的 Excel实用程序。这款工具也是我的

Power Utility Pak UI建议不译)插件的组件之一。Text Tools”实用程序可让用户操作选定范围的的单元格内的文本。这款实用程序具体可帮助用户进行一下操作:

更改文本的样式(大写、小写、首字大写、语句样式或大小写转换)。

在文本中添加字符(在文本的首尾或特定的字符位置)

移除文本中的字符(在字符串的首尾或者字符串内的特定位置)

删除文本中的空格符(所有空格或多余的空格).

在文本中删除字符(非打印字符、字母符号、非数字符号、非字母符号或数字符号)

第四部分:高级编程技巧

14-1显示的是“Text Tools”实用程序对话框。

14-1使用“Text Tools“实用工具来更改选定文本的样式。

TextTools”实用程序在本书的网站上提供下载。该工具是 Power Utility Pak中附带的工具的独立版本,文件名为 texttools.xlam,是一款标准的Excel插件。在安装的时候,会向菜单中新增一个按钮Ribbon: HomeUtilities

TextTools”。 VBA project未使用密码保护,这样您就可以查看其代码来了解其工作原理,或者做一些更改来更好地满足您的需求。


转载请注明作者出处及原文链接,否则将追究法律责任:

作者:xiangsir

原文链接:http://blog.csdn.net/xiangsir/article/details/17534385

QQ:444367417

MSN:xiangsir@hotmail.com


 


  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值