Microsoft Word and Delphi

Formatting Tables in Word with Delphi

Page 1 of 1

1 Replies - 5693 Views - Last Post: 26 June 2007 - 01:35 AM Rate Topic: -----

#1 Liezel  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 25-April 07

Microsoft Word and Delphi

Posted 25 June 2007 - 03:51 AM

Hi I need to change the vertical alignment of the cells of a table in Word, using Delphi. I can left and right align, but I can't find how to align top or bottom. I need to bottom align my table.

I have created a table in Word with Delphi like this:

Word: _Application;
S: OleVariant;
R : OleVariant;
Direction, Separator, Format: OleVariant;

//Some code to open file and start Word etc, etc.

//Then I create table like this
S := Word.Selection;
R := Word.Selection.Range;
Direction := wdCollapseEnd;
R.Collapse(Direction);

XmlParser.ParseFile; //This just adds strings to R

Separator := ',';
Format := wdTableFormatGrid1;
R.ConvertToTable(Separator, EmptyParam, EmptyParam,
EmptyParam, Format, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);

//Left align text in cells
R.ParagraphFormat.Alignment := wdAlignParagraphLeft;

Word.Visible := True;
////////////////////////////////////////////////////////////////
How to do vertical alignment?
I have tried this line of code but it doesn't work, (borrowed from how it is done in Excel).
R.ParagraphFormat.VerticalAlignment := wdVAlignCenter;

Anyone have ideas for me?

Is This A Good Question/Topic? 0
  • +

Replies To: Microsoft Word and Delphi

#2 Liezel  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 25-April 07

Re: Microsoft Word and Delphi

Posted 26 June 2007 - 01:35 AM

I found my answer. Here it is for anyone interessed.

R.Cells.VerticalAlignment := wdCellAlignVerticalBottom;


(R := Word.Selection.Range;)
Was This Post Helpful? 1

Page 1 of 1