Visual Basic for Applications

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar

Microsoft VBA (Visual Basic for Applications) is the Microsoft Visual Basic macro language used to program Windows applications and is included in several Microsoft applications. VBA allows users and programmers to extend the functionality of programs in the Microsoft Office suite. Visual Basic for Applications is a nearly complete subset of Visual Basic 5.0 and 6.0.

Microsoft VBA comes integrated into Microsoft Office applications such as Outlook, Word, Excel, Access, and Powerpoint. Just about anything that can be programmed in Visual Basic 5.0 or 6.0 can also be done within an Office document, with the only limitation that the final product cannot be compiled separately from the document, sheet, or database in which it was created.; that is, it becomes a macro (or rather super macro). This macro can be installed or distributed simply by copying the document, presentation, or database.

Its main utility is to automate everyday tasks, as well as create applications and database services for the desktop. It allows access to the functionalities of an event-oriented language with access to the Windows API.

Since it comes from a Basic-based language, it has similarities with languages included in other office automation products such as StarBasic and Openoffice.

Sub LoopTableExample

Dim db As DAO.Database
Dim rcs As DAO.Recordset

Set db = CurrentDb
Set rcs = db.OpenRecordset("SELECT * FROM tblMain")

Do Until rcs.EOF
MsgBox rcs!FieldName
rcs.MoveNext
Loop

Close
db.Close
Set rcs = Nothing
Set db = Nothing
End Sub

VBA can be used to create a user-defined function for use in a Microsoft Excel sheet:

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

VBA also has access to internal Windows functions to varying degrees, and can access resources from schedules to files to control:

Sub GetDate()

MsgBox "The date is " & Format(Now(), "dd-mm-yyy")


End Sub

The language can be accessed by entering the tools menu. And once there MACRO and VISUAL BASIC EDITOR.

Future

The next natural step in the evolution of VBA is to move from being a subset of Visual Basic to being a subset of the.NET platform. Microsoft does not plan to make significant improvements to VBA in the future. Although it will continue to support the VBA licenses that have been offered, VBA is being replaced by Microsoft Visual Studio Tools for Applications (VSTA) and Microsoft Visual Studio Tools for Office (VSTO: Visual Studio Tools for Office). These tools work under the.NET platform.

As of July 1, 2007, Microsoft no longer offers new VBA licenses to new customers. Those who owned a VBA license will be able to get a license for the new solutions from Microsoft.

Contenido relacionado

FastCGI

FastCGI is a protocol for interfacing interactive programs with a web...

Obsolescence

Obsolescence is the state of being that occurs when an object, service or practice is no longer maintained or required even though it is still in good working...

VR6 engine

The VR6 engine is an internal combustion engine whose arrangement consists of six cylinders at a narrower angle than usual. It was developed by Volkswagen in...
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save