A macro is the name used to describe lines of code that are used to automate repetitive tasks in Microsoft Office.
These lines of code are written in a language called VBA which is an abbreviation for Visual Basic for Application.
VBA is the language behind all the Microsoft Office applications (inc. Excel, Word, PowerPoint, Outlook, Access).
Macros run inside the office application and require no additional software.
The terms 'macro' and 'VBA Code' are equivalent and refer to the same thing.
Macros can perform tasks a lot quicker than they can be done manually and often with greater accuracy.
There are two ways to create a macro.
You can either use the Macro Recorder or you can write the statements directly into the Visual Basic Editor (Alt + F11).
There is a different object model for each of the Office applications and it is organised is a tree like structure.
An object model defines the objects, properties and methods that can be used in your code to control the application.
These can be anything really, workbooks, documents, paragraphs, ranges, slides etc.
All VBA objects are either singular objects or objects in a collection.
Objects in a collection are referenced by an index in the collection.
Most of the time your code can operate on objects without activating or selecting them.
Every object model consists of a list of objects.
Excel has over 300 different objects.
For example in Excel there is a Worksheet object a Chart object and a Cell object.
Programs consist of sequences of statements.
Each statement must end with a new line.
A statement that evaluates to a value is called an expression.
A subroutine is a series of statements that performs a specific task.
A function is identical to a subroutine but also has the ability to return a value.
A code module is the name of the component that contains a group of subroutines and functions
There are a number of operations that macros/vba cannot perform:
Create ActiveX Controls
Integrate with Visual Source Safe
Create ActiveX Dynamic Link Libraries
Use or Integrate between multiple projects
Reuse any Visual Basic Component
Create OLE Automation Servers
© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopNext