《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’redeveloping utilities for other users, what makes an Excel utility valuable? I’ve put together a list ofelements that are common to good utilities:? It adds something to Excel. This addition could be a new feature, a way to combine existingfeatures, 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 worksin 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 specialtouch to utilities is tempting, other users will find them easier to use if they look and act likefamiliar Excel commands and dialog boxes.? It provides help for the user when needed. In other words, the utility should have documentationthat’s thorough and accessible.? It traps errors. An end user should never see a VBA error message. Any error messages thatappear should be ones that you write.? Users can undo its effects. Users who don’t like the result caused by your utility should beable to reverse their path.

Text Tools: The Anatomy of a UtilityIn this div, I describe an Excel utility that I developed and use frequently. It’s also part of myPower Utility Pak add-in. The Text Tools utility enables the user to manipulate text in a selected rangeof cells. Specifically, this utility enables the user to do the following:? Change the case of the text (uppercase, lowercase, proper case, sentence case, or togglecase).? 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 positionwithin the string).? Remove spaces from the text (either all spaces or excess spaces).? Delete characters from the text (nonprinting characters, alphabetic characters, non-numericcharacters, 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 thetool included with the Power Utility Pak. The file, named text tools.xlam, is a standardExcel 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 thecode 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: Home”?“Utilities”?

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

作者:xiangsir

QQ:444367417

MSN:xiangsir@hotmail.com

原以为“得不到”和“已失去”是最珍贵的,可原来把握眼前才是最重要的。

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

相关文章:

你感兴趣的文章:

标签云: