The ZoomToReferenceScale VBA macro shows how to programmatically execute the built-in command in a context menu. Setting the ContextItem property is the key.
How to use
- Open a map document, click the menum item of View->Data Frame Properties..., and choose General tab to set the reference scale.
- Paste the ZoomToReferenceScale macro into a module in the Visual Basic Editor.
- Run the macro to execute the command.
Public Sub ZoomToReferenceScale()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
pDoc.ContextItem = pDoc.FocusMap
Dim pCmdItem As ICommandItem
Set pCmdItem =
Application.Document.CommandBars.Find(arcid.DataFrameView_ZoomToReferenceScale)
pCmdItem.Execute
End Sub