Working across applications
Visual Basic can create new objects and retrieve existing objects from many Microsoft applications. Other applications may also provide objects that you can create by using Visual Basic. See the application's documentation for more information.
' Start Microsoft Excel and create a new Worksheet object. Set ExcelWorksheet = CreateObject("Excel.Sheet") ' Start Microsoft Excel and open an existing Worksheet object. Set ExcelWorksheet = GetObject("SHEET1.XLS") ' Start Microsoft Word. Set WordBasic = CreateObject("Word.Basic")
Most applications provide an Exit or Quit method that closes the application whether or not it is visible. For more information about the objects, methods, and properties an application provides, see the application's documentation.
Dim X As New Field
This case is an example of a class in the data access type library. A new instance of a Field object is created by using this syntax. Refer to the application's documentation for information about which object classes can be created in this way.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.