visual basic is the language for programming in word, access,& excel is the “environment”...
TRANSCRIPT
Visual Basic
Is the language for programming in Word, Access,& Excel
Is the “Environment” in which the programming is done (called the Integrated Development Environment or IDE)
Visual Basic
Objects / Properties / Methods
Object
Property
Method
Noun
Adjective
Verb
Visual Basic
Range (“A3”).select
Range is an object
select is a method
(“A3”) is a modifier for the object
Note that object separated from method by a .
Activesheet.name
Activesheet is an object
name is a property
Visual Basic
The result is the name of the active sheet
Visual Basic
All objects have properties
Most objects have methods
Will work with only a few of the many objects, methods and properties
Will introduce them as needed
Visual Basic
Some of the objects
WorkbookWorksheetActiveSheetRangeFormChart
Note --- a “Cell” is not an object, but is a type of range object
Visual Basic
And to further confuse the issue objects can have objects as properties
And objects can be grouped into collections
Workbook = collection of worksheets
Visual Basic -- The Environment
From Excel --- toggle with alt F11
Notice 3 parts to the IDE
The Project areaThe Properties area
The blank (or work area)
We will use primarily the properties and work areas
Macros are a type of VBA module
“Recorded Macros” are exactly that A record of the key strokes
converted to VB code
Keyboard Macros
Quick way to develop a macro
Captures keystrokesAssigns a name & shortcut
Two places to store
Current workbookPersonal workbook
Current workbook
Macro only available in the workbook
Stays with the workbook
Personal workbook
Available to all workbooks you create in currentsession.
Does not travel with current workbook
Stored in a special area and needs to be opened.
Recorded keystrokes macros, if saved in current workbook, are VBA subprograms in the “modules” component of the IDE. Good way to look at how Excel is manipulated.
If saved in the Personal Workbook, will see the Personal Workbook available in the IDE Project window. Are in a module of the Personal workbook
Can record macros in two modes:
Absolute address mode – referenced cells are absolute addresses (i.e. $col$row)
Relative address mode – referenced cells are relative to the selected cell when the macro is recorded. That is, cell addresses may change each time macro is run.
We will use recorded macros primarily as a way to introduce VBA programming.
But you should be able to find a good use for them – great for repeated tasks.
We will develop a couple of macros today and explore VBA more over the next wLabs.