Set the Shape.OnAction-Property

Add-in Express™ Support Service
That's what is more important than anything else

Set the Shape.OnAction-Property
But does not work as expected! 
Andre Hass




Posts: 3
Joined: 2007-09-11
hi,

i tried to set the OnAction-Property to an ShapeObject by an ADX COM Add-In.


  ...

  if Length(pictFile) > 0 then
  begin
    Shw := Sheet.Shapes.AddPicture(pictFile, TOleEnum(False), TOleEnum(True), l, t, w, h);
    Shw.Name := pictName;
    Shw.OnAction := 'OnClick';
  end;

  Result := pictName;
end;



So far, so good, but if I click on this Shape-Object in Excel, this Function is not executed!



procedure TQRFuncs.OnClick();
var
  dispShape: MyShape;
  dispShapeRange: MyShapeRange;
  V: OleVariant;
begin

  try
    try
      V := OleVariant(Instance.ExcelApp.Selection[adxLCID]).ShapeRange;
      dispShapeRange := MyShapeRange(TVarData(V).VDispatch);
      if Assigned(dispShapeRange) then
      begin
        dispShape := dispShapeRange.Item(1);
        dispShape.TopLeftCell.Select;
      end;
    finally
      dispShape := nil;
      dispShapeRange := nil;
      V := Unassigned;
    end;
  except
  end;
end;



What went wrong? Is it possible to handle this event in this way?

Thanks in advanced!
Posted 29 Oct, 2007 05:53:06 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Andre,

---
OnAction property:
Returns or sets the name of a macro that?Â?Ð?és run when the specified object is clicked.
---

You can try to use the OnSheetSelectionChange or OnSheetChange events.


Posted 29 Oct, 2007 06:00:51 Top
Andre Hass




Posts: 3
Joined: 2007-09-11
I also feared thats the reason for. Thanks Dmitry!
Posted 29 Oct, 2007 06:17:43 Top