Vba 00
Vba 00
ISBN: 0-9759828-7-7
Library of Congress Control Number: 2006931790
Official book website: http://www.projectvbabook.com
All rights reserved. You may not reproduce or transmit any part of this work in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information
storage or retrieval system, without the prior written consent of the copyright owner and the
publisher.
We use trademarked names in this book in an editorial context and to the benefit of the trademark
owner with no intention of infringement of the trademark.
Published and distributed by Soho Corp. dba MSProjectExperts, 90 John Street, Suite 404, New
York, NY 10038 (646) 736-1688 http://www.msprojectexperts.com
We provide the information contained in this book on an as is basis, without warranty. Although
we make every effort to ensure the accuracy of information provided herein, neither the authors
nor the publisher shall have any liability to any person or entity with respect to any loss or
damage caused or allegedly caused directly or indirectly by the information contained in this
work.
EPM Learning
EPM Learning is a complete series of role-based training manuals for professional trainers and
corporate training programs. To learn more about the EPM Learning courseware series for
Technical Administrators, PMO Administrators, Project Managers, Resource Managers,
Executives and Team Members, or to obtain instructor companion products and materials,
contact Soho Corp. by phone (646) 736-1688 or by email [email protected].
Contents
About the Author .............................................................................. xi
About the Editors ............................................................................ xii
Introduction ....................................................................................xiii
Module 02: Common VBA Code for All Office Programs .......... 21
Using Office VBA Code ................................................................ 23
Adding Comments to Your Code.................................................. 23
Understanding Objects, Methods, Properties, and Parameters ... 24
Using the With Statement ........................................................... 27
Using the MsgBox Function ......................................................... 29
Prompting the User for Inputs .................................................... 30
Understanding Functions and Procedures ................................... 31
Using Help to Learn More about VBA........................................... 33
iii
Contents
iv
Contents
Contents
Module 16: Creating the Project Control Center Macro ......... 195
Structuring Your Macros ........................................................... 197
Project Control Center Macro Overview .................................... 198
Designing the Project Control Center .......................................... 198
vi
Contents
vii
Contents
viii
Contents
Module 29: Accessing Project Server Data from Excel .......... 415
Understanding the PJSVRDB.HTM File....................................... 417
Weekly Reporting on Project Server Data ................................. 418
Looping through All Projects ...................................................... 418
Starting Project Professional and Logging into Project Server ......... 419
Setting up the Excel Report ....................................................... 421
Reading a List of All Project Titles ............................................... 421
Reading Milestone and Current Task Data.................................... 425
Reading all Issues and Risks for a Project .................................... 427
Writing the Final VBA Code for the Excel Report Macro .................. 431
Creating a Project Program Report ........................................... 435
ix
Contents
Index.................................................................................... 451
xi
xii
Introduction
Thank you for reading VBA Programming for Microsoft Office Project,
Versions 98 Through 2007. This book teaches you to develop VBA macros for
Microsoft Project that are productive, quick to develop, and easy to maintain.
The learning examples included in this book give you a great jump start for
your own Project VBA programming projects. I document an array of useful
macros, including routines for viewing all tasks linked to the selected one,
automatically creating a consolidated snapshot of multiple project files, a
Who Does What When report exported to Excel, and more. In this book, I
teach you how to write VBA macros for Microsoft Project by explaining how to
design them for easier code maintenance.
For those of you new to VBA programming, Section 1 explains the part of
Project VBA that is common to VBA for all Microsoft Office applications.
Section 2 is specific to Project VBA and covers the full range of skills you
need to automate Microsoft Project. Section 3 documents how to read and
write data to Project databases and how to report on projects in a Project
Server database.
By reading this book, I believe you will be much more effective as a VBA
programmer. If you have specific questions, contact me in the public
Microsoft Project newsgroup (server msnews.microsoft.com):
microsoft.public.project.developer
If you are still finding programming Project VBA a hard task, please feel free
to e-mail me at [email protected] to discuss how I can help you.
Rod Gill, Microsoft Project MVP
xiii
xiv