| Visual Basic For Applications |
Article Index for Visual Basic |
Website Links For Visual Basic |
Information AboutVisual Basic For Applications |
| CATEGORIES ABOUT VISUAL BASIC FOR APPLICATIONS | |
| basic programming language family | |
| microsoft office | |
|
DESCRIPTION Visual Basic for Applications ('''VBA''') is an implementation of Microsoft 's Visual Basic which is built into all Microsoft Office applications (including Apple Mac OS versions), some other Microsoft applications such as Microsoft Visio - a former independent application which was acquired by Microsoft; as well as being at least partially implemented in some other applications such as AutoCAD and WordPerfect . It supersedes and expands on the capabilities of earlier application-specific Macro Programming Languages such as Word's WordBasic, and can be used to control almost all aspects of the host application, including manipulating user interface features such as menus and toolbars and working with custom user forms or dialog boxes. VBA can also be used to create import and export filters for various file formats, such as ODF . As its name suggests, VBA is closely related to Visual Basic , but can normally only run code from within a host application rather than as a Standalone Application . It can however be used to control one application from another (for example automatically creating a Word report from Excel data). VBA is functionally rich and extremely flexible but it does have some important limitations, including limited support for Callback functions. It has the ability to use (but not create) ( ActiveX/COM ) DLL 's and later versions add support for class modules. USAGE Most software products (Autodesk AutoCAD / Microsoft Office / Adobe Illustrator) provide an 'Object Model' to the Visual Basic Environment allowing the user to create anything from small macros that perform repetitive tasks to extensive programs that add functionality to the host program. LITERATURE
EXAMPLES VBA is useful for automating database tasks such as traversing a table: Sub LoopTableExample Dim db '''As''' DAO.Database Dim rs '''As''' DAO.Recordset Set db = CurrentDb
Do Until rs.EOF MsgBox rs!FieldName rs.MoveNext Loop rs.Close db.Close Set rs = '''Nothing''' Set db = '''Nothing''' End Sub VBA can be used to create a user defined function (UDF) for use in a Microsoft Excel workbook: Public Function BUSINESSDAYPRIOR(dt As Date) As Date Select '''Case''' Weekday(dt, vbMonday) Case 1 BUSINESSDAYPRIOR = dt -3 Case 7 BUSINESSDAYPRIOR = dt -2 Case Else BUSINESSDAYPRIOR = dt -1 End '''Select''' End Function EXTERNAL LINKS |
|
|