The ShowArcCatalog VBA macro demonstrates how to programmatically start the ArcCatalog application and move the ArcCatalog window from ArcMap. You need to use the Application Running Object Table object, AppROT, to get a reference to any running ArcMap or ArcCatalog application.
How to use
- Start ArcMap and paste this code into a module in the Visual Basic editor.
- Run the ShowArcCatalog macro. This should start an ArcCatalog application and position the window.
Sub ShowArcCatalog()
Dim pAppROT As AppROT
Dim pAppROTCountInt As Integer
Dim pAppROTCount As Integer
Dim pCommand As ICommandItem
Dim pAppWin As IWindowPosition
Dim i As Integer
Set pAppROT = New AppROT
pAppROTCountInt = pAppROT.Count
' Start ArcCatalog in ArcMap
Set pCommand = Application.Document.CommandBars.Find(ArcID.Tools_Catalog)
pCommand.Execute
' Wait for the new ArcCatalog application to be added to AppROT
Do Until pAppROTCount = (pAppROTCountInt + 1)
pAppROTCount = pAppROT.Count
Loop
' Get a reference to the running ArcCatalog application and move its window
If TypeOf pAppROT.Item(pAppROTCount - 1) Is IGxApplication Then
Set pAppWin = pAppROT.Item(pAppROTCount - 1)
' Move the ArcCatalog application window
pAppWin.Move 10, 10, 600, 500
End If
End Sub