Excel formatting problems

forum.advanced.programming (1998-2005)

Excel formatting problems

Post by Carsten » 07 Dec 2004, 22:40

 Posted by:  Carsten 


in general I do have the problem to work well with the Excel 9 object
library apl. Is there any documentation for that? It didn't come with
the library so I need to dig for every piece of functionality. Can
anyone of you please direct me to some kind of doc?

The specific question I have is how to format data in an excel cell. So,
what I found out is how to set characters to bold, but this doesn't seem
to work for the alignment. What I'm currently looking for is setting the
cell alignment to centered.

Thank you all for any help!!

Regards, Carsten

Sebastien Huleux

Excel formatting problems

Post by Sebastien Huleux » 08 Dec 2004, 13:08

 Posted by:  Sebastien Huleux 

Somewhere in your office folder there should be a help file called
VBAXL10.CHM, for me in \Program Files\Microsoft Office\Office10\1033,
detailing all the excel object model.

To set the alignement:

Call oApp.PropGetActiveCell( oRange ) ! or any other call to get the range
for cells you want to change
Call vAlignement .SetNumber( xlHAlignCenter, VT_I4 ) ! or any one of the
xlHAlign* constants
Call oRange.PropSetHorizontalAlignment( vAlignement )

Same for vertical alignement, use PropSetVerticalAlignment( ) using the
xlVAlign* constants.



Excel formatting problems

Post by Carsten » 13 Dec 2004, 23:14

 Posted by:  Carsten 

Thanks, Sebastien, that did the trick. Is there any file though where
all the constants are defined? I figured out the value of xlHAlignCenter
by searching the internet even though I do have the Office library
linked in my app.

I do have another problem now which is also related to formats: Starting
from e.g. cell E3 down to the bottom I need to format numbers with 3
decimal places so that all numbers look like this:


Thanks again, guys, I really appreciate it a lot.

Best regards, Carsten

Return to “advanced.programming”

Who is online

Users browsing this forum: [Ccbot] and 0 guests