Simple Visual Basic Key Concepts 2 Simple VB

Simple Visual Basic • Key Concepts • 2 Simple VB Procedures • Simple VB Applications - take with • Other Examples - time permitting Contents

Simple Visual Basic • Object Libraries (aka APIs) • Allows you to control one Microsoft Office application from another. Microsoft Project’s Object Library is a hierarchical organization of “things” contained in a Microsoft Project file (a collection of collections). Project Resources Tasks Assignments Actions Other Stuff Dependencies From Deps To Deps Key Concepts – Object Libraries

Simple Visual Basic • Excel Workbook? Workbook Actions Worksheets Other Stuff Rows Columns Cells Actions Key Concepts – Object Libraries

Simple Visual Basic • Exchanging Data between Object Libraries & Applications. Project File Resources Tasks Assignments Actions Dependencies From Deps To Deps Key Concepts – Object

Simple Visual Basic • Use VB to Get data from Object Libraries Project File Resources Tasks Assignments Actions Dependencies Tools/Macro/Visual Basic Editor Key Concepts – Writing VB

Simple Visual Basic VB Procedures can be written in a project file or in a Global file Key Concepts – Writing VB

Simple Visual Basic VB Procedures are written in a “notepad like” environment Key Concepts – Writing VB

Simple Visual Basic VB Procedures are called Sub statements and are written between the Sub and End Sub line A good practice is to Declare Objects that you plan to use with a line that starts with Dim (Dim t as task tells VB that t is a reference to Task Objects) Key Concepts – Writing VB

Simple Visual Basic • Simple VB to get values from a project file • For/Next Loop – moves VB from one task to the next: For each Task in Active. Project. Tasks Msg. Box Task. Name Next Task This example starts with the first task in a project, displays a message box containing the task name, then continues to the next task until the end of the project is reached. Simple VB Procedure 1

Simple Visual Basic • Simple VB to get values from a project file • If/Then – tests if a condition exists: For each Task in Active. Project. Tasks If Task. Summary = True Then Msg. Box Task. Name End if Next Task In this example, the message box will display only if a task is a summary Simple VB Procedure 2

Simple Visual Basic VB Form

Simple Visual Basic VB Procedures may not run if your security settings are set to the highest level. Select Tools/Macro/Security to change security level. VB Security Settings You can add a digital signature to a macro you write (Tools/Digital Signatures in the VB editor). That lets users know that your VB is safe to run.

Simple Visual Basic If you plan to use objects from an application’s object library, you must select those libraries in the References form (Tools/References in VB editor) Shown to the right are the libraries used in the SSI Tools examples VB Object Library References
- Slides: 13