Code Examples For RunCommand Constants

Activate An OLE Field

acCmdOLEObjectDefaultVerb

This example activates an OLE field on a form.

'***************** Code Start *******************
' This code was originally written by Terry Wickenden.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.

Sub ActivateOleObject()

  On Error GoTo ErrOle

  Screen.PreviousControl.SetFocus
  RunCommand acCmdOLEObjectDefaultVerb
  Exit Sub

ErrOle:

  Select Case Err
    Case 2046
      'Command not available
      MsgBox "You must select an OLE field before running this procedure.", vbCritical, "Not Available"
    Case 2501
      'Cancel selected in dialog box - do nothing
    Case Else
      MsgBox Err.Number & ":-" & vbCrLf & Err.Description
  End Select

End Sub

'****************** Code End ********************