OCC Network Drives  H:\  P:\  https://myfiles.oakton.edu/

Slides:



Advertisements
Similar presentations
ITEC 1001 Tutorial 1 Using Common Features of Microsoft Office 2003.
Advertisements

Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Microsoft Office Excel 2013 Core Microsoft Office Excel 2013 Core Courseware # 3253 Lesson 8: Macros, Importing and Exporting Data.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
With Microsoft Excel 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Excel 2010.
Advanced Microsoft Word Hosted by Jared Hoffman Topics Keyboard Shortcuts Customizing Toolbars and Menus Auto Format & Auto Correct Tabs Inserting Pictures.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Using the Visual Basic Editor Visual Basic for Applications 1.
XP 1 Using Common Features of Microsoft Office 2003 Rod Rodrigues.
XP Using Common Features of Microsoft Office Tutorial 1.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Macros in Excel Intro to lab 1. Macroinstructions Macro is recorded in VBA module sequence of Excel operations Macros can automate tasks in Excel Macro.
Excel Lesson 14 Creating and Using Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
ADVANCED MICROSOFT POWERPOINT Lesson 6 – Creating Tables and Charts
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Macros and VBA A macro is a set of instructions that tells Excel which commands to execute.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Word Lesson 16 Working with Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
Microsoft Office Word 2013 Core Microsoft Office Word 2013 Core Courseware # 3250 Lesson 8: Using Productivity Tools.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Office 2007 Word Integration Feature Linking an Excel Worksheet and Chart to a Word Document.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 1 – Access Basics.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
XP New Perspectives on Introducing Microsoft Office XP Tutorial 1 1 Introducing Microsoft Office XP Tutorial 1.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
1 CA201 Word Application Increasing Efficiency Week # 13 By Tariq Ibn Aziz Dammam Community college.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 7Automating, Customizing, and.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
1 ADVANCED MICROSOFT WORD Lesson 16 – Customizing Features Microsoft Office 2003: Advanced.
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
The Object Model Visual Basic for Applications 2.
Working with option button, check box, and list box controls Visual Basic for Applications 13.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
By Felixberto Dominic B. Eruela.  Using a computer to create, edit, and print documents. Of all computer applications, word processing is the most common.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Pasewark & Pasewark 1 Office Lesson 1 Microsoft Office 2007 Basics and the Internet Microsoft Office 2007: Introductory.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Excel Tutorial 8 Developing an Excel Application
Chapter 1: An Introduction to Visual Basic 2015
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Introducing VBA Macros
Macro.
Microsoft Excel 2007 – Level 2
Presentation transcript:

OCC Network Drives  H:\  P:\ 

Introducing the Visual Basic Editor (Unit 1) Visual Basic for Applications

Objectives  In this unit, you’ll learn how to:  Recognize the components of the Visual Basic Editor  Enter code using the Visual Basic Editor  Create a procedure  Internally document a procedure  Display a message in a dialog box  Run, save, and print a procedure

Concept Lesson: Procedures  Visual Basic for Applications (VBA) is the programming language found in many Microsoft and non-Microsoft products  You can use VBA to customize an application to fit your needs  You do so by creating a procedure, which is simply a series of VBA instructions grouped together as a single unit for the purpose of performing a specific task

Procedures  You can run some procedures, called macros, directly from the Macros dialog box  Other procedures, called event procedures, run in response to specific actions you perform on an object  Those actions—such as opening a document, activating a worksheet, or clicking a command button—are called events

Working with Macros in Office 2007  Enable developer tab  Adjust macros security setting  Save as PowerPoint Macro-Enabled Presentation  Powerpoint 2003 shortcut to create macros:  ALT+T M R

PowerPoint Options

Macro Security Setting Disable all macros with notification is safer

Available switches and parameters for Office PowerPoint 2007  /B  Start PowerPoint with a new blank presentation.  Example: "c:\program files\microsoft office\office12\POWERPNT.exe" /B  /M MACRO  Run a macro in a specified presentation.  Example: "c:\program files\microsoft office\office12\POWERPNT.exe" /M myfile.pptm "MyMacro" ("MyMacro" is a macro in the file myfile.pptm)

The Visual Basic Editor  The host application is the application in which you are working  The Visual Basic Editor contains three separate windows:  The main window  The Project Explorer window  The Properties window  Visual Basic Editor will have a similar interface in every application in which it is contained  The main window, at the top of the screen, contains the title bar, the menu bar, and the Standard toolbar

The Visual Basic Editor Opened in Microsoft Excel Exhibit 1-1: The Visual Basic Editor opened in Microsoft Excel

The Visual Basic Editor  The Project Explorer window displays a list of the open projects and their components  A Module object is simply a container that stores macros and other procedures that are not associated with any specific object in the project  Every VBA object has a set of characteristics, called properties, associated with it that control the object’s appearance and behavior  These properties, along with their values, are listed in the Properties window

The Visual Basic Editor  The Toggle Folders button controls the display of the folders in the Project Explorer window  The Project Explorer window operates similarly to the Windows Explorer window in that a plus sign next to a folder indicates that the folder contains objects  You can use the View Object button to view the object whose name is selected in the Project Explorer window  When an object is selected in the Project Explorer window, you can use the View Code button to open its Code window

The Visual Basic Editor  In the Code window, you enter the VBA instructions, called code, that instruct a procedure on how to perform a task  You enter your VBA instructions between the Public Sub and End Sub lines in the Code window  The Public Sub line denotes the beginning of the procedure whose name follows the word Sub, and the End Sub line marks the end of the procedure  A keyword is a word that has a special meaning in a programming language

Code Window Showing the MorningMsg Procedure Exhibit 1-2: The Code window showing the MorningMsg procedure

The Visual Basic Editor  A sub procedure refers to a block of code that performs a specific task, but does not return a value  Function procedures, which are designated by the keyword Function, are procedures that can return a value  The keywords Public and Private indicate the procedure’s scope, which determines which objects can use the procedure  A Public scope indicates that the procedure can be used by all objects within the project

The Visual Basic Editor  A Private scope indicates that the procedure can be used only by the object in which the procedure is contained  The keyword End indicates the end of something  The `display message line is a comment  The Object list box either will display the word (General), or it will display the type of object associated with the Code window  The Procedure list box displays the name of the current procedure

The Visual Basic Editor  Sometimes scroll bars will appear on the Procedure list box to indicate that not all of the procedures are currently displayed  You can use Full Module View to view procedures in the code window as a single, scrollable list, or you can use Procedure View to view one procedure at a time.

Entering Instructions in the Code Window  You can enter VBA instructions into a Code window by directly typing each instruction in its entirety, or the Visual Basic Editor can assist you in entering the instructions  The Visual Basic Editor can provide assistance in two ways:  by displaying a listing of an object’s properties and methods after you type the object’s name followed by a period in the Code window  by displaying the syntax, or programming language rules, of a command as you are entering it in the Code window

Entering Instructions in the Code Window  A method is a predefined VBA procedure, which is simply a procedure that the Microsoft programmers have already coded for you  If your preference is to have the Visual Basic Editor assist you when entering instructions, you need to enable  Auto List Members  Auto Quick Info check boxes  When the Auto List Members check box is selected, the Visual Basic Editor will display an object’s members after you type the object’s name followed by a period

Entering Instructions in the Code Window Exhibit 1-3: The member list for the Application object

Entering Instructions in the Code Window  The properties and methods are listed in alphabetical order, and the list contains a scroll bar, which indicates that not all of the members can be viewed at the same time  The period between the object and its property is known as the dot member selection operator  When the Auto Quick Info check box is selected on the Editor tab of the Options dialog box, the Visual Basic Editor displays the syntax of the command you are typing in the Code window  The term syntax refers to the rules of a programming language

Saving a Procedure  You save a VBA procedure by saving the file that contains the procedure  You can use the Save command on the File menu, the Save button on the Standard toolbar, or the key combination Ctrl+S to save the file  After saving a procedure, you then run it to verify that it is working correctly

Running a Procedure  While in the Visual Basic Editor, you can use either the Run menu or the Tools menu to run a procedure  You also click the Run procedureType button on the Standard toolbar or you can press the F5 key  The method you use to run a procedure from the host application depends on the type of procedure being run  Event procedures run automatically in response to the occurrence of an event, such as the opening of a document or the clicking of a command button

Printing a Procedure  You provide external documentation by printing a copy of the procedure’s code; you can do so by right-clicking the project’s name in the Project Explorer window, and then clicking Print on the shortcut menu  You also can use the Print command on the Visual Basic Editor’s File menu, or you can press Ctrl+P

Summary To open the Visual Basic Editor:  On the host application press Alt+F11, to open the VBE (Visual Basic Editor) To open the Project Explorer window, which contains a listing of the open projects and their components:  Click View on the Visual Basic Editor menu bar and then click Project Explorer To open the Properties window, which contains a listing of properties along with their default values:  Click View on the Visual Basic Editor menu bar, and then click Properties Window

Summary  To view the Standard toolbar in the Visual Basic Editor main window:  Click View on the Visual Basic Editor menu bar, point to Toolbars, and then click Standard  To control the display of the items in the Project Explorer window:  Click the Toggle Folders button  To display an object:  Click the object’s name in the Project Explorer window, and then click the View Object button

Summary  To open an object’s Code window:  Click the object’s name in the Project Explorer window and then click the View Code button  To have the Visual Basic Editor assist you when entering instructions in the Code window:  Click Tools on the Visual Basic Editor menu bar and then click Options  To document a procedure:  Provide internal documentation by entering comments in the Code window

Summary  To display each procedure in a separate Code window:  Click the Procedure View button in the Code window  To display an object’s code as a single listing in the Code window:  Click the Full Module View button in the Code window  To save a procedure:  You save a procedure by saving the file that contains the procedure

Summary To run a procedure in order to verify the accuracy of its instructions:  While in the Visual Basic Editor, you can use either the Run menu or the Tools menu to run a procedure; you also can use the Run procedureType button on the Standard toolbar or you can use the F5 key To print a procedure:  Display the Print dialog box by using the Print command on the Visual Basic Editor’s File menu, or by pressing Ctrl+P, or right-clicking the object’s name in the Project Explorer window and then clicking Print on the shortcut menu

Coding the Workbook Object’s Open Event Procedure  To save and run the workbook’s Open event procedure you need to open the workbook

Coding the GetGenius Macro Procedure  A macro is a procedure that the user can run from the Macro dialog box in Excel  Before you can create a macro, you first must insert a Module object into the current project

Coding the DisplayDate Macro Procedure  Unlike the Open event procedure, which runs automatically when someone opens the New Member document, you want to be able to run the DisplayDate procedure whenever you choose to do so  For that to happen, the DisplayDate procedure will need to be a macro procedure

Access Lesson: Using the Visual Basic Editor in Microsoft Access  As you learned in the Concept lesson, you can use VBA to customize an application to fit your needs  You do so by creating a procedure, which is simply a series of VBA instructions grouped together as a single unit for the purpose of performing a specific task

Coding the Form Object’s Close Event Procedure  An event procedure runs in response to an action performed on an object by the user  A form’s Close event procedure runs automatically when the user closes the form

Coding a procedure in Access  You may want a macro to perform a task for which no action exists in the Macro window’s Action list  In those cases, you need to use the Visual Basic Editor to create a function procedure, and then you use the Action list’s RunCode action to include the procedure in the macro  The RunCode action tells the macro to run the code contained in the function procedure