Welcome to Dream.In.Code
Become an Expert!

Join 149,523 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,434 people online right now. Registration is fast and FREE... Join Now!




Microsoft Word and Delphi

 
Reply to this topicStart new topic

Microsoft Word and Delphi, Formatting Tables in Word with Delphi

Liezel
25 Jun, 2007 - 02:51 AM
Post #1

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 9


My Contributions
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?


User is offlineProfile CardPM
+Quote Post

Liezel
RE: Microsoft Word And Delphi
26 Jun, 2007 - 12:35 AM
Post #2

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 9


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

R.Cells.VerticalAlignment := wdCellAlignVerticalBottom;


(R := Word.Selection.Range;)
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month