Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.

Slides:



Advertisements
Similar presentations
Using VB with MS Applications R. Juhl, Delta College.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
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.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
Automating Tasks With Macros
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Using the Visual Basic Editor Visual Basic for Applications 1.
Adding Automated Functionality to Office Applications.
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.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Access Tutorial 10 Automating Tasks with Macros
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
© 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.
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 7Automating, Customizing, and.
Microsoft Excel Macros & Excel Solver (IENG490)
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 11 Committed to Shaping the Next Generation of IT Experts. Chapter 10 Customizing a Database.
Key Applications Module Lesson 21 — Access Essentials
MS Access: Introduction 1Database Design. MS Access: Overview MS Access A Database Management System (DBMS) designed to create applications that organize,
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
® Microsoft Access 2010 Tutorial 10 Automating Tasks with Macros.
Access Lesson 11 Creating and Running Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
1 MIS309 Database Systems Introduction to Microsoft Access.
Microsoft Access Lesson 2 Lexington Technology Center February 13, 2003 Bob Herring On the Web at
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Introduction to Excel VBA UNC Charlotte CPE/PDH Series December 17, 2009.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Introduction to Microsoft Excel Macros COE 201- Computer Proficiency.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
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.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Computer Fundamentals
Microsoft Access Illustrated
Using Procedures and Exception Handling
Microsoft Excel 2003 Illustrated Complete
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Chapter 7 Advanced Form Techniques
Exploring Microsoft Office Access 2007
Macro.
Tutorial 10 Automating Tasks with Macros
Tutorial 11 Using and Writing Visual Basic for Applications Code
Tutorial Introduction to help.ebsco.com.
Microsoft Excel 2007 – Level 2
Presentation transcript:

Automating Tasks with Visual Basic

Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.  Example: − Modify a whole batch of records at once. − Perform complex calculations. − Interact with other programs on computer. − Write even more complicated validation routines that lock out bad data.

Understanding VBA Terminology  Some basic VBA terminology: − Statement: A word or combination of words that constitutes an instruction to be performed by the VBA engine. − Procedure: A collection of VBA statements that are grouped together to perform a certain task. There are two types of procedures:  Subroutines: perform a single task, no return.  Functions: perform a task and then return a value

Understanding VBA Terminology − Module: Procedures live in modules. A module consists of one or more procedures − Variable: is nothing more than a name applied to represent a data value. Variable is used to hold values such as customer names, dates, and numeric values manipulated by the VBA code.

The Visual Basic Editor  Visual Basic code is stored in database, but it need a different tool to view and edit it, called the Visual Basic editor.  Open the Visual Basic editor:  In the Access ribbon, choose Database Tools ➝ Macro ➝ Visual Basic

The Visual Basic Editor  The Visual Basic editor window is divided into three main regions. − Project window: shows all the modules in your database. − Properties window: which shows settings for the currently selected item in the Project window. − Document window: Edit code region.

Adding a New Module  In the Visual Basic editor’s menu, choose Insert ➝ Module.

Adding a New Module  When add a new module, the Visual Basic editor automatically opens a code window that shows the contents of that module.  Initially, a brand-new module has just one line of code: Option Compare Database − This line is an instruction that tells Visual Basic how to handle operations that compare pieces of text.

Adding a New Module  Before write code you should add one more instruction to the top of code file: Option Explicit  This instruction tells Visual Basic to use stricter error checking, which catches common typos when using variables.

Simplest Possible Code Routine  Every module are one or more subroutines. A subroutine is a named unit of code that performs a distinct task.  Subroutines start with the word Sub followed by the name of the subroutine and end with the statement End Sub  Example: Sub MyCodeRoutine() MsgBox "Witness the power of my code." End Sub

Module types  Access stores code in two places: − Class modules: attached to the form or report, it executes when the form or report is opened, the class module does not appear in the modules section. − Standard modules: Code can also be stored in modules section. Standard modules is accessible to all objects in your database.

Responding to a Form Event  Open a form in Design mode.  Turn off Control wizard button.  Add a new button.  Inthe Property Sheet, choose the Event tab, and then select the button’s On Clickevent  Click the ellipsis (…) in the On Click Event box  Select Code Builder and click OK