Board index » delphi » Curious Word Picture into Table.Cell issue

Curious Word Picture into Table.Cell issue


2003-07-29 11:49:40 PM
delphi178
Dear all,
I have a curious issue/bugette - I wonder if anyone has ever came across it or something like this before?
Basically, I am inserting a picture into a table.cell, using:
procedure TWordAPI.InsertPictureIntoCell(fileName: String; tbl: OleVariant; column: Integer; row: Integer);
var
varFalse, varTrue: OleVariant;
OleRange: OleVariant;
begin;
try
varTrue := True;
varFalse := False;
OleRange := Tbl.Cell(column, row).Range;
Tbl.Cell(column, row).Range.InlineShapes.AddPicture(filename, False, True, OleRange);
except
on e: exception do
HandleException('InsertPicture', e );
end;
end;
which works fine. However, the cell in which I insert the picture (which is small) does *not* resize to accommodate the picture - instead most of the picture is hidden behind other cells in the table. Additionally even if I resize the cell in code to the size of the picture, the picture seems anchored to the top-left of the cell.
The funny thing is that previously (before this afternoon), the cell *did* resize properly and everything was fine, but it suddenly stopped working and started displaying the behaviour above.
Does anyone know why this is the case?
Best,
Dave
 
 

Re:Curious Word Picture into Table.Cell issue

"Dave M." <XXXX@XXXXX.COM>writes:
Quote

Dear all,
I have a curious issue/bugette - I wonder if anyone has ever came across it or something like this before?

<snip>
Hello all, after a lot of experimenting, I managed to solve this issue, and I thought I'd post the solution here incase anyone else had this problem.
Anyway, I eventually discovered my problem was due to the wrap type not being set correctly for the inserted picture. The following piece of code (late-binding) inserts the picture correctly in the table cell:
var
AddedInlineShape: OleVariant; // Word2000.Inlineshape
AddedShape: OleVariant; // Word2000.Shape;
OleRange: OleVariant; // Word2000.Range
varFalse: OleVariant;
varTrue: OleVariant;
begin;
try
varTrue := True;
varFalse := False;
OleRange := Tbl.Cell(column, row).Range;
AddedInlineShape := Tbl.Cell(column, row).Range.InlineShapes.AddPicture(filename, varFalse, varTrue, OleRange);
AddedShape := AddedInlineShape.ConvertToShape;
AddedShape.WrapFormat.Type := wdWrapTight;
AddedShape.Top := 0;
except;
// Usual Exception Handling
end;
Best,
Dave
(replace NOSPAM with eims to reply)