Excel automation

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

Excel automation
 
Jon Chen




Posts: 36
Joined: 2007-04-10
Hi,

I like to set values on certain cells from within an Excel Com Add-In. Do you have any examples? Btw, is there any reference documentation like class, property, method and event for all VCL components? Thanks.

-Jon
Posted 18 Sep, 2007 13:41:35 Top
Dmitry Kostochko


Add-in Express team


Posts: 2741
Joined: 2004-04-05
Hi Jon,

You can use the Cells or Range properties. Please see the code below:


procedure TAddInModule.adxCommandBar1Controls0Click(Sender: TObject);
var
  IWorkSheet: _Worksheet;
begin
  if ExcelApp.Workbooks.Count 
>
 0 then begin
    ExcelApp.[B]ActiveCell[/B].Value := 'Test';
    ExcelApp.ActiveSheet.QueryInterface(IID__Worksheet, IWorkSheet);
    if Assigned(IWorkSheet) then
      try
        IWorkSheet.[B]Range[/B]['A1', EmptyParam].Value := 'Test';
        IWorkSheet.[B]Cells[/B].Item[5, 5].Value := 'Test';
      finally
        IWorkSheet := nil;
      end;
  end;
end;




Posted 19 Sep, 2007 06:12:28 Top
Jon Chen




Posts: 36
Joined: 2007-04-10
Dmitry,

I used the code sample in the TAddinMoudle IMPL unit and it worked fine. However I cannot use it in other form. Can you tell me what unit I should include (uses) in order to use 'ExcelApp' object? Thanks.

-Jon
Posted 28 Sep, 2007 10:36:18 Top
Dmitry Kostochko


Add-in Express team


Posts: 2741
Joined: 2004-04-05
Hi Jon,

Please see the following topic:
http://www.add-in-express.com/forum/read.php?FID=1&TID=1884

Posted 28 Sep, 2007 12:51:43 Top
Jon Chen




Posts: 36
Joined: 2007-04-10
Dmitry,

Thanks for the response.

I created a separate form and use Show to display the form. The edit box in that form cannot get the focus for entering data. It seems to get the focus, but when I type, Excel gets the entered text. How do I resolve this problem?

The reason I use Show instead of ShowModal is when I click a button on the form I can set value to cells (with RTD formula) and see result right away.

Thanks.

-Jon
Posted 28 Sep, 2007 14:04:09 Top
Dmitry Kostochko


Add-in Express team


Posts: 2741
Joined: 2004-04-05
Hi Jon,

I am afraid the problem with keyboard input in a non-modal form in the Excel add-in cannot be solved. I'd recommend using the ShowModal method only.


Posted 01 Oct, 2007 06:58:12 Top