PDA

View Full Version : Table Cell Alignment (vla-SetCellAlignment)


matt.bellenoit
2007-10-03, 08:22 PM
can anyone shed some light on what I'm doing wrong with this... here's my code all I want to do is set the cell alignment on an existing table to Middle Left justified...

(setq Tbl (vlax-EName->vla-Object (car (entsel))))
(setq rowcnt (vla-get-rows Tbl))
(setq rowhgt (vla-getRowHeight Tbl 2))
(if (/= rowhgt 0.253333)(setq rowhgt 0.253))
(setq clal (vla-GetCellAlignment Tbl rowcnt 3)) ;is this even needed?!!
(vla-SetCellAlignment Tbl rowcnt 3 acmiddleleft)
(vla-InsertRows Tbl rowcnt rowhgt 1)

I'm guessing I'm not using the setcellalignment right... Help anyone?!

RobertB
2007-10-03, 10:49 PM
The GetCellAlignment isn't needed, you aren't using the value anywhere.

SetCellAlignment only works on a single cell. You've attempted to feed the method a "range".

matt.bellenoit
2007-10-04, 12:48 PM
Ok so how would I go about setting the cell alignment to middle left for the cell in the 4th column of a given row? I'm lost... been at this thing for days!! lol

can you give me an example of the correct formatting of the alignment command?

Thanks for the info... I'm relooking at it now and just getting more confused!

matt.bellenoit
2007-10-04, 03:25 PM
Figured it out!!

and again... Thanks for the help Robert!

(setq Tbl (vlax-EName->vla-Object (car (entsel))))
(setq rowcnt (vla-get-rows Tbl))
(setq rowhgt (vla-getRowHeight Tbl 2))
(if (/= rowhgt 0.253333)(setq rowhgt 0.253))
(vla-InsertRows Tbl rowcnt rowhgt 1)
(vla-SetCellAlignment atbl rowcnt 3 acmiddleleft)

RobertB
2007-10-04, 05:45 PM
Glad to help.