Code Examples For RunCommand Constants

Display the Insert Object Dialog

acCmdInsertObject

This code opens the Insert Object dialog. It checks that the previous control was actually an OLE object field. The code needs to be put behind a button called cmdInsertOLE.

'***************** Code Start *******************
'Code by Terry Wickenden

Private Sub cmdInsetOLE_Click()
  On Error GoTo errInsertOLE

  Screen.PreviousControl.SetFocus
  RunCommand acCmdInsertObject
  Exit Sub

errInsertOLE:

  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 ********************