Provides access to other objects in the document.
Use the IDocument interface to get access to the document's title, type, accelerator table, commandbars collection, parent application, and Visual Basic project. Use IApplication::Document to get a reference to the document.
| Description | ||
|---|---|---|
![]() |
Accelerators | The accelerator table for this document. |
![]() |
CommandBars | The commandbars collection in this document. |
![]() |
ID | The unique id for this document. |
![]() |
Parent | The application in which this document is open. |
![]() |
Title | The title of this document. |
![]() |
Type | The type of this document. |
![]() |
VBProject | The VBProject for this document. |
| CoClasses and Classes | Description |
|---|---|
| GMxDocument (esriArcGlobe) | Provides access to members that control the ArcGlobe document. |
| GxDocument (esriArcCatalog) | ESRI ArcCatalog Application Document. |
| MxDocument (esriArcMapUI) | ESRI Mx Document. |
| SxDocument (esriArcScene) | Provides access to members that control the ArcScene document. |
The document object is called MxDocument in ArcMap and GxDocument in ArcCatalog.
Each VBA project contains a VBA class called ThisDocument. This class represents the document object. When you are working in the ThisDocument code window in VBA, you have direct access to the properties and methods on the IDocument interface.
The following VBA macro turns off all the toolbars in the application.
Sub HideBars()
Dim pApp As IApplication
Set pApp = Application
Dim pDoc As IDocument
Set pDoc = pApp.Document
Dim pCmdBars As ICommandBars
Set pCmdBars = pDoc.CommandBars
pCmdBars.HideAllToolbars
End Sub
Since all the VBA projects have a class for the document object called ThisDocument, the above macro can be shortened to the following.
Sub HideBars()
Dim pCmdBars As ICommandBars
Set pCmdBars = ThisDocument.CommandBars
pCmdBars.HideAllToolbars
End Sub
If you write this macro in the ThisDocument code window, this example can be shortened even further. Sub HideBars()
CommandBars.HideAllToolbars
End Sub
IApplication.Document Property