Adding Automated Functionality to Office Applications.

Slides:



Advertisements
Similar presentations
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
Advertisements

Tutorial 7: Developing an Excel Application
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.
Automating Tasks With Macros
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
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.
Automating with Macros Today we are going to at how to automate frequently used processes with macros: What is a macro? What do we want to automate? How.
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.
Computer Science & Engineering 2111 Data Validation and Macros 1 CSE 2111 Lecture-Data Validation and Macros.
Languages and Environments Higher Computing Unit 2 – Software Development.
With Microsoft Excel 2007 Comprehensive 1e© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Excel 2007 Comprehensive.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
© 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-
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.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Learning about Expert Systems through computer programming.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter 12: How Long Can This Go On?
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
VBA Lab 2 I ns.Samia Al-blwi. Visual Basic Grammar Object: Visual Basic is an object-oriented language. This means that all the items in Excel are thought.
OCC Network Drives  H:\  P:\ 
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Chapter 9 Macros And Visual Basic For Applications.
Creating Macros in Excel Adding Automated Functionality to Excel & Office Applications.
ME 142 Engineering Computation I Using Subroutines Effectively.
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.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Excel Macros 1 Macros or, How to Automate Part of Your Spreadsheet or Worksheet.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Controlling Program Flow with Decision Structures.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Macros in Excel Using VBA Time Required – 5 hours.
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
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Microsoft Access 2003 Illustrated Complete
Microsoft Access Illustrated
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Introducing VBA Macros
Exploring Microsoft Office Access 2007
Creating Macros in Excel
Exploring Microsoft Excel
Macro.
Lesson 1 - Automating Tasks
Microsoft Excel 2007 – Level 2
Presentation transcript:

Adding Automated Functionality to Office Applications

Macros A macro is a series of written instructions or recorded keystrokes and mouse actions. With a single keystroke, users can play back these activities at a much faster speed than those same actions can be performed manually. Macros can help eliminate wasted time and the risk of error that typically occur when performing repetitive tasks.

Two different ways macros are created Keystroke Macros – Perform a sequence of operations using keystrokes and the mouse and the application records what you are doing Writing programming code to accomplish a task. Both options use Visual Basic for Applications (VBA). The difference is how the VBA code is created

File tab Select OPTIONS Customize Ribbon Select DEVELOPER as one of the main tabs

Recording 2 Macros First macro: Sum all columns Second macro – Sum all columns – Paste values into a Copy row – Deletes answer row (from first step)

Recording Macros Benefits – Quick and easy way to add automated functionality to your spreadsheet. The macro recorder simply records the keystrokes that you take or mouse actions that you perform – Code is guaranteed to be free from syntax/coding errors – Can serve as a starting point if you are inexperienced. Weaknesses – The macro recorder does not write the most efficient code. It records actions and commands you might not need or want. – May have to record macro several times due to making errors in the recording process. More chances for making errors. – If changes are made to the document (add column or row), the macro may not function as intended. Not as robust – Works well for basic tasks, but sometimes you want advanced functionality that recorded macros can’t make possible (button tasks)

Visual Basic for Applications (VBA) Write programming code to accomplish a task.

Visual Basic for Applications (VBA) is a programming language – VBA is a subset of Visual Basic – VBA requires a host application Excel, Access, PowerPoint, Word – You can customize an Excel workbook or enhance Access database objects. Create your own custom functions Perform calculations using variables and constants Create buttons that initiate process tasks (clicking button results in something happening) Display messages to users Automate tasks rather than repeatedly doing something Visual Basic for Applications (VBA)

Procedures (also known as sub procedures or event procedures) are programming instructions that tell the computer what to do. Words in green are comments (not executable): apostrophe ‘comment Blue text signifies VBA keywords (reserved words) that have special meaning Black text is regular text you have added Indenting segments of code improves readability.

VBA is an object-oriented programming language: objects are created and then methods/actions are taken to manipulate to those objects. When a program is running, it needs to be able to accept input, perform calculations and then display output. Input boxes and text boxes (located on a form or in an application) are used to obtain input for users while a program is running.

Programs use constants and variables – Constants store values that never change – Variables store values that can vary or change while the program is running. Data types – Use string for alphanumeric data (letters, numbers, symbols) – Use one of the numeric data types if the data will be used in a calculation.

Typically, a computer program executes instructions sequentially (in the order they are written). This is called a sequence structure. However, there are two notable exceptions – Decision Structure A comparison is made, and based upon the results of the comparison, the program executes statements in a certain order – IF statements – IF…Then…Else statements(including ElseIf) – Select Case – Repetition Structure Repeats the execution of certain statements while a certain condition is true OR until a condition is true – For…Next – Loops » Do While » Do Until

IF…Then statements specify what should happen if a condition is true, but there is no alternative if the statement is false. IF…Then…Else statements specify what should happen if a condition is true and what should happen if a condition is false. Just like our IFs in Excel.

Select Case Select Case allows you to test one value against multiple conditions, and based upon the category something is in, it returns the appropriate result. – This is much easier to create and understand than nesting Ifs inside other Ifs.

Repetition Structures Repeats the execution of statements while a certain condition is true OR until a condition is true For….Next statements repeat execution a certain number of times. Do Loops repeat steps until something has happened or while something has not happened. Do until or Do while