Académique Documents
Professionnel Documents
Culture Documents
rea
rea
i
s
functionality
to the UserForms.
Chapter 5 explores charting in Excel 2007. After examining the code created by t
he Macro
Recorder, it shows how to use the Chart object in code.
Chapter 6 takes a look at Excel PivotTable reports. PivotTables are powerful dat
a analysis
tools, and they re easy to create and modify. The code samples show how to create
and modify
PivotTable reports.
Chapter 7 is an overview of VBA debugging tools and techniques. The Immediate, L
ocals,
and Watch windows are shown in detail. The section on error handling shows how t
o effectively
trap for errors and how to provide positive feedback to the user.
Chapter 8 is all about integrating your Excel solution with other Microsoft Offi
ce applications.
Its examples include building a chart report in Word 2007 and building a PowerPo
int
presentation that includes text and charts from an Excel workbook.
Chapter 9 shows how to use components built in Visual Basic 6 and Visual Studio
2005 in
your Excel 2007 projects. Examples from earlier chapters are re-created using Ac
tiveX technologies
in Visual Basic 6 and .NET assemblies using Visual Studio 2005 and Visual Studio
Tools for Office 2005.
Prerequisites
Microsoft Excel 2007 is required for the examples in this book. For Chapter 8, Of
fice Integration,
you ll need Microsoft Word 2007 and PowerPoint 2007.
SQL Server 2005 Management Studio Express is used in our SQL data examples. This
is available for download from the Apress web site (www.apress.com), in the Sour
ce Code/
Download section.
To create the code for Chapter 9, ActiveX and .NET, you ll need Visual Basic 5 or 6
(for
the ActiveX section) and Visual Studio 2005 and Visual Studio Tools for Office 2
005 SE (for the
.NET section). If you do not have one or both of the above, the compiled compone
nts for each
example are provided on the Apress web site. The .NET Framework 2.0 should be in
stalled on
your PC for the .NET examples to run. If you do not have Visual Studio 2005, you l
l be able to
run the samples, but you won t have direct access to the code.
xviii nINTRODUCTION
Downloading the Code
The source code for this book is available to readers at www.apress.com, in the
Source Code/
Download section. Please feel free to visit the Apress web site and download all
the code there.
You can also check for errata and find related titles from Apress.
Contacting the Author
Contact Jim DeMarco at jim.demarco@hcheq.org. For more information on HCHEQ and
its mission, go to www.hcheq.org. For information on Jim s musical endeavors, go t
o www.
fiftyhabit.com or contact him at info@fiftyhabit.com.
nINTRODUCTION xix
The Macro Recorder and
Code Modules
This book is written for experienced coders. You may have experience in many lan
guages,
but not in the Excel (or Office) VBA IDE. We will be writing quite a bit of code
as we move
along, but before we do that, let s take a quick look at Excel s Macro Recorder and
the Visual
Basic Development Environment. The Macro Recorder has been a part of Excel for q
uite a
long time, and it s still the best way to get a look at some of the objects that m
ake up the Excel
Document Object Model (DOM), and a great way to get the core of your code writte
n for you
as you start your development projects.
Macro Security Settings
Excel s default security settings do not allow any macro activity. Before you begi
n exploring
macros in Excel and the Macro Recorder, you will need to tell Excel which securi
ty settings to
use to control what happens when you open a workbook that contains macros (or on
e that
will contain macros). If you use antivirus software that works with Microsoft Of
fice 2007 and
you open a workbook that contains macros, the virus scanner will check the workb
ook for
viruses before opening it.
You can make changes to the macro security settings in the Trust Center:
1. Click the Microsoft Office button, which looks like the following:
2. Click the Excel Options button, select Trust Center, click the Trust Center S
ettings
button, and finally click the Macro Settings item.
Alternatively, on the Developer ribbon, click the Macro Security button in the C
ode Group
section. (Depending on the network security level at your organization, you may
or may not
have rights to change these settings).
nNote Macro setting changes made in Excel s Macro Settings section apply to Excel
only; they do not
affect any other Microsoft Office applications.
1
C H A P T E R 1
Table 1-1 lists the Excel macro security settings and explains each setting.
Table 1-1.Macro Security Settings
Setting Purpose
Disable all macros without notification Use this setting if you don t trust the so
urce of
a workbook containing macros.
Disable all macros with notification This is the default setting. Use it when yo
u
want macros to be disabled, but you want to
get security alerts if there are macros present.
You can decide when to enable those macros.
Disable all macros except digitally signed macros This is the same as the Disable
all macros
with notification option, except that when
the macro is digitally signed by a trusted publisher,
the macro can run if you have trusted
the publisher.
Enable all macros (not recommended, potentially Use this setting to allow all ma
cros to run.