Introduction
W
elcome to your first look at Visual Basic for Applications (VBA)!
You might think that VBA is a secret code used by advanced com-
puter users to intimidate the rest of us. Nothing could be further from the
truth. VBA is all about doing things your way. When you want an application
to perform a task in a certain way, use VBA to extend it. VBA makes
you
the
boss. After you
discover the wonders of VBA, you can customize a number
of applications to make them work the way you want them to work.
VBA is a tool that empowers you to perform tasks you never thought possible
in a fraction of the time that it takes to perform the task by hand. For exam-
ple, you can add new toolbars, create custom reports, and perform special
kinds of data analysis. When you write a VBA program, you become the
master of your environment — someone who gets the job done quickly.
Over 500 readers of the previous edition
of this book sent me e-mail, many of
whom told me about their current projects. After reviewing those messages
for this edition of the book, I can truly say that VBA is an amazing tool because
you’re doing amazing things with it. After seeing everything that people are
doing with VBA, it’s easy to say that this is the tool for everyone!
About This Book
VBA For Dummies,
5th Edition, is a reference book. You don’t
have to read it
in any particular order, and you can skip anything that you don’t find inter-
esting. Readers who have VBA programming experience can skip to the
advanced examples at the end of the book or explore new language elements
as needed. That said, I did put the book into a logical order. When you begin
at Chapter 1 and progress through the book chapter by chapter, you acquire
a
complete view of VBA, even if you’ve never used it.
This book contains many examples from my own library. I write VBA pro-
grams for all my applications that support it because I know that using VBA
can save me time and effort. In addition, I write VBA programs for some of my
consulting clients. This real-world approach to using VBA will help you get
started quickly.
Some of the new examples are the result of my experiments with the new
Ribbon interface. You’ll find that the Ribbon adds a new dimension to work-
ing with VBA and that it breaks some of your older code. Fortunately, you’ll
find many of the answers for fixing your applications in this book.
03_046500 intro.qxp 12/5/06 5:32 PM Page 1
Conventions
Used in This Book
I always try to show you the fastest way to accomplish any task. In many cases,
this means using a menu command, such as Tools
➪
Macro
➪
Visual Basic Editor.
When you’re working with the Ribbon, I’ll tell you which tab to access first
and then which feature to use on that tab.
I’m assuming that you’ve worked with Windows long enough to know how
the keyboard and mouse work. You should also know how to use menus and
other basic Windows features.
Whenever possible, I use shortcut keys to help you access a command faster.
For example, you can also start the VBA Integrated
Development Environment
(IDE) by pressing Alt+F11.
This book also uses special type to emphasize some information. For exam-
ple, entries that you need to type appear in
bold
. All code, Web site URLs,
and onscreen messages appear in
monofont type
. Whenever I define a new
word, you’ll see that word in
italics
.
Because you use two applications when working with VBA, I always tell
you to move from one application to the next.
When a chapter begins, I
assume that you’re in the VBA IDE unless I tell you otherwise. All the com-
mands in that chapter are for the VBA IDE until I specifically tell you to move
to the host application. I also specifically tell you when it’s time to move
back to the VBA IDE.
What You Should Read
What you read depends on your level of experience — you need to know
how to use at least one Microsoft Office application. It also helps to know
something about VBA before you tackle the programs at the end of the book.
With this in mind, you probably want to read Chapters 1 through 7 in order
before you begin discovering other parts of the book.
You might have used VBA before and want to
know only what you can add
to your knowledge. The programs become progressively more complex
and application specific as the book progresses. When you want to find out
how to work with Word only, feel free to select Chapter 13. You might find
Chapter 17 a good place to start because, in it, I tell you about interesting
VBA resources that you might not know about. Of course,
all
the content in
this
book is great, and I hope that you eventually read it all.
2
Do'stlaringiz bilan baham: