Using VB with MS Applications R. Juhl, Delta College.

Slides:



Advertisements
Similar presentations
Microsoft ® Office OneNote ® 2007 Training Using your Notebook to its fullest potential Kent School District presents:
Advertisements

Introduction to Macro Introduction to Visual Basic for Application Recording a Macro Looking at the code of Recorded Macro.
AS ICT Finding your way round MS-Access The Home Ribbon This ribbon is automatically displayed when MS-Access is started and when existing tables.
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
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.
Microsoft Office 2007 Microsoft Excel Collaboration Feature Using SharePoint and Excel Services.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Professor Joe Perret Pierce College Transition to Microsoft Office 2007.
Using the Visual Basic Editor Visual Basic for Applications 1.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Computers Are Your Future © 2008Prentice-Hall, Inc.
Integrating Word, Excel, Access, and PowerPoint
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
FIRST COURSE Integration Tutorial 3 Integrating Word, Excel, Access, and PowerPoint.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #2: The Visual Basic Editor The Visual Basic for Applications Programming Language IE 212: Computational.
Microsoft Excel 2000 Adding Visual Elements and Managing Files.
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.
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.
Microsoft Excel Macros & Excel Solver (IENG490)
Learning Microsoft Power Point Getting Started  There are three features that you should remember as you work within PowerPoint 2007: the Microsoft.
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.
CHAPTER 9 Introducing Microsoft Office Learning Objectives Start Office programs and explore common elements Use the Ribbon Work with files Use.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Computers Are Your Future © 2005 Prentice-Hall, Inc.
Integrating Word with Other Programs Microsoft Office Word 2007 Illustrated Complete.
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.
OCC Network Drives  H:\  P:\ 
Key Applications Module Lesson 21 — Access Essentials
Chapter Two Creating a First Project in Visual Basic.
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.
FIRST COURSE Integration Tutorial 1 Integrating Word and Excel.
® Microsoft Office 2010 Integrating Word, Excel, Access, and PowerPoint.
® Microsoft Office 2010 Integrating Word, Excel, Access, and PowerPoint.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Introduction to Microsoft Excel Macros COE 201- Computer Proficiency.
FIRST COURSE PowerPoint Tutorial 4 Integrating PowerPoint with Other Programs and Collaborating with Workgroups.
MODULE 9 Integrating Word, Excel, Access, and PowerPoint © Paradigm Publishing, Inc.1.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Chapter 28. Copyright 2003, Paradigm Publishing Inc. CHAPTER 28 BACKNEXTEND 28-2 LINKS TO OBJECTIVES Table Calculations Table Properties Fields in a Table.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Chapter 2: The Visual Studio .NET Development Environment
Outline In this module, the following topics will be covered:
3.01 Apply Controls Associated With Visual Studio Form
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
Microsoft Office Illustrated
How to Create a PBWorks Site
Computers Are Your Future
Microsoft PowerPoint 2007 – Unit 2
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Using VB with MS Applications R. Juhl, Delta College

Visual Basic for Applications (VBA) VBA works with many applications including Microsoft Office Use VBA to: accomplish tasks automatically Event driven or when a user generates a stimulus change the application environment VBA is integrated with all Microsoft Office products In Office 2007 you have to enable VBA MS Word, Excel, and Powerpoint Located in the Developer Tab MS Access Located on the “Database Tools “ Tab

To enable VBA Click on: ‘Show Developer tab in the Ribbon’

The “Developer Tab” is now added:

Note that other 2007 Office products: Visio Project Publisher and previous products in Office 2003 do not use the Ribbon Interface.

You access VBA in these products by selecting the: Tools  Macro menu

Other product s use VBA, too: In reference to our text book…….. MSDN or Microsoft Developer Network website States Microsoft's position on Licensing VBA Contains Support links for using VBA

Use VBA to automate : Documents Compose letters by picking predetermined text Spreadsheets Click a button for predefined automatic data entry Database Importing Data and performing calculations Labor Loading

Use VBA to automate : Customizing an application interface Create new version of features Exclude unwanted information Include only the information needed Performing calculations Change data before you use it Simplify by using small steps rather than large

Select the ‘Visual Basic’ Icon from the ‘Developer’ Menu

The Integrated Development Environment Parts

Project Explorer Contains List of items in the project Contains all project elements in a single file VB Application exists within project file

The Integrated Development Environment Parts Properties Contains Properties or Attributes of the object selected Color Words on it Boolean attributes Password

The Integrated Development Environment Parts Code Contains The VB code needed to make the application Subroutines Functions Procedures

IDE Supports Forms: You decide: What appears on the form How the form acts / user interaction Use the toolbox To create controls used in forms Text Box, Labels, Check box, etc… More in Chapter 7

A note on objects Your VBA programs will contain objects A form could be an object The Apple Metaphor Properties ? Methods ?

A note on objects Your VBA programs will contain objects A form could be an object The Apple Metaphor Properties ? (color, taste) Methods ?

A note on objects Your VBA programs will contain objects A form could be an object The Apple Metaphor Properties ? (color, taste) Methods ?

A note on objects Your VBA programs will contain objects A form could be an object The Apple Metaphor Properties ? (color, taste) Methods ? ( pick, eat )

o A note on objects Your VBA programs will contain objects A form could be an object The Apple Metaphor Properties ? (color, taste) Methods ? (pick, eat ) Events ? ( changes color over time )

o Setting up security (to run macros / VBA)

Select the Developer or Database Tools Tab Click Macro Security Using Project Explorer Interact with the objects that make up the project Objects listed depend on the application

Project Explorer - Word Project Documents Doucment Templates Project Explorer - Excel Project Worksheets Workbooks Project Explorer - Access Project Database(s)

Project Explorer can also contain other objects: Forms – User interface Modules – Nonvisual code Class Modules – Contain new object to build

Project Explorer – Right click to find context menu properties (more in chapter 3)

Working with special entries In Word you may see a reference folder

Working with special entries In Word you may see a reference folder

Working with special entries In Word you may see a reference folder It may contain templates In many cases you can’t modify objects in the special folder Its used for information only You normally don’t need to work with these objects

Using the Properties Window Most objects in the VBA IDE have properties Properties describe objects Some common properties are: text boolean i.e. visible property may be True False

Using the Properties Window Object properties may also have: Numeric value i.e. to place a control use the left / top properties set to numbers Drop down list Color property For help with properties Highlight the property and press F 1

Using the Code Window Where you write application code Sub SayHello() ' Display the message box Result = MsgBox("Click a Button Please", vbYesNoCancel, "A Messege") 'See which button the user pressed. MsgBox Result End Sub

Using the Code Window Where you write application code Sub SayHello() ' Display the message box Result = MsgBox("Click a Button Please", vbYesNoCancel, "A Messege") 'See which button the user pressed. MsgBox Result End Sub

Using the Code Window To open existing code Click on the module folder and open the module you want to edit.

Using the Code Window The code window also automatically appears when you perform other tasks When you double click on a forms control: The code window opens for that control Allows you to edit code for the event handler that corresponds to the control

Creating a new code window From the IDE select Insert  Module It appears as a new code window It appears as a module in the Project / Module folder

Typing text in the Code window If you make an error VBA checks what you type.

The code window has a context menu (right click)

Code context help is available by right- clicking the key code word

Using the Immediate window Select View  Immediate Window

You can type code directly into the immediate window to test…

The immediate window remembers the variable state…. Using MyVar in the previous slide and typing MsgBox Myvar

IDE Object Browser Use View  Object Browser

The Object Browser Provides all the VBA objects at your disposal Objects are the fundamental building block of Visual Basic; Nearly everything you do in Visual Basic involves modifying objects. Every element of Microsoft Word — documents, tables, paragraphs, bookmarks, fields and so on — can be represented by an object in Visual Basic.

The Object Browser Provides all the VBA objects at your disposal Objects are the fundamental building block of Visual Basic; Nearly everything you do in Visual Basic involves modifying objects. Every element of Microsoft Word — documents, tables, paragraphs, bookmarks, fields and so on — can be represented by an object in Visual Basic.

The Object Browser Lists Libraries of: Objects Modules Forms Methods Projects And their properties / Functions

The Object Browser Applications Library has the name of the application

The Object Browser Office Library Lists Objects that Microsoft Office supports Used to find support for Office Assistant 2003 The Object Browser also contains the current VBA project

The Object Browser Lists StdOLE Library Object Linking and Embedding Embed a picture in a document Link one document to anther VBA Library Special Utility Objects MsgBox function

The Object Browser Searching Type in the keyword / method etc….

You can cut & paste from the Object Browser by: Selecting the item Clicking the Double Document Icon Copies to the clipboard Then pasting directly into your application