140 likes | 281 Views
Contents. Simple Visual Basic. Key Concepts 2 Simple VB Procedures Simple VB Applications - take with Other Examples - time permitting. Key Concepts – Object Libraries. Simple Visual Basic. Object Libraries (aka APIs) Allows you to control one Microsoft Office application from another.
E N D
Contents Simple Visual Basic • Key Concepts • 2 Simple VB Procedures • Simple VB Applications - take with • Other Examples - time permitting
Key Concepts – Object Libraries Simple Visual Basic • Object Libraries (aka APIs) • Allows you to control one Microsoft Office application from another. Project Microsoft Project’s Object Library is a hierarchical organization of “things” contained in a Microsoft Project file (a collection of collections). Resources Tasks Actions Other Stuff Assignments Dependencies From Deps To Deps
Key Concepts – Object Libraries Simple Visual Basic • Excel Workbook? Workbook Actions Worksheets Other Stuff Rows Columns Cells Actions
Simple Visual Basic Key Concepts – Object Exchange • Exchanging Data between Object Libraries & Applications. Project File Resources Tasks Actions Assignments Dependencies From Deps To Deps
Simple Visual Basic Key Concepts – Writing VB • Use VB to Get data from Object Libraries Project File Resources Tasks Actions Assignments Dependencies Tools/Macro/Visual Basic Editor
Simple Visual Basic Key Concepts – Writing VB VB Procedures can be written in a project file or in a Global file
Simple Visual Basic Key Concepts – Writing VB VB Procedures are written in a “notepad like” environment
Simple Visual Basic Key Concepts – Writing VB 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)
Simple Visual Basic Simple VB Procedure 1 • Simple VB to get values from a project file • For/Next Loop – moves VB from one task to the next: • For each Task in ActiveProject.Tasks • MsgBox 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 Visual Basic Simple VB Procedure 2 • Simple VB to get values from a project file • If/Then – tests if a condition exists: • For each Task in ActiveProject.Tasks • If Task.Summary = True Then • MsgBox Task.Name • End if • Next Task • In this example, the message box will display only if a task is a summary
Simple Visual Basic VB Form
Simple Visual Basic 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. VB Procedures may not run if your security settings are set to the highest level. Select Tools/Macro/Security to change security level.
Simple Visual Basic VB Object Library References 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