Share via


AddCommand method

Adds a command to the Tools menu to call a COM add-in.

Applies to

Objects:  Application

Syntax

object.AddCommand(DisplayName, MethodName, Target)

Parameters

Part Description
object Required. An expression that returns an Application object.
DisplayName Required String. The name of the menu command to be added to the Tools menu. Should be a unique name. Use the ampersand (&) to indicate an accelerator key. Use two ampersands (&&) to add an ampersand to the menu.
MethodName Required String. The method exposed by the add-in to implement the command.
Target Required Object. The add-in object that implements the method.

Remarks

In the MapPoint Control, this method does nothing because there are no menus to modify.

To learn more about creating COM add-ins, see the About creating a COM add-in reference topic.

Example

  
      Dim moaApp As MapPoint.Application
  Public Sub SayHello()
    MsgBox "Hello"
  End Sub

  Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As
  AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
  On Error GoTo error_handler

    Set moaApp = Application
    'Add this command to the menu
    moaApp.AddCommand "Saying Hello", "SayHello", Me

    Exit Sub

  error_handler:

    MsgBox Err.Description

  End Sub