Home All Groups Group Topic Archive Search About

text justification in excel

Author
12 Jul 2006 2:05 PM
krollenhagen
I am creating an excel spreadsheet from vb.net 2005.  I followed the
advice of some other posts on how to "Center Text in Excel" by creating
a macro in excel to do what I want and then looking at the code.

"oSheet.Range("F3").HorizontalAlignment = xlRight" is what was posted
there.  When I try this, I get an error of "xlRight is not declared"

What do I declare it as?

Thanks

Author
12 Jul 2006 2:51 PM
Chris
krollenhagen wrote:
> I am creating an excel spreadsheet from vb.net 2005.  I followed the
> advice of some other posts on how to "Center Text in Excel" by creating
> a macro in excel to do what I want and then looking at the code.
>
> "oSheet.Range("F3").HorizontalAlignment = xlRight" is what was posted
> there.  When I try this, I get an error of "xlRight is not declared"
>
> What do I declare it as?
>
> Thanks
>

Look at what type of object HorizonatlAligment expects.  It will be
something system.something.horizontalAligment.xlright
chris
Author
12 Jul 2006 3:19 PM
krollenhagen
It works as an integer.  Center is 3, Right is 4

Thanks.

Chris wrote:
Show quoteHide quote
> krollenhagen wrote:
> > I am creating an excel spreadsheet from vb.net 2005.  I followed the
> > advice of some other posts on how to "Center Text in Excel" by creating
> > a macro in excel to do what I want and then looking at the code.
> >
> > "oSheet.Range("F3").HorizontalAlignment = xlRight" is what was posted
> > there.  When I try this, I get an error of "xlRight is not declared"
> >
> > What do I declare it as?
> >
> > Thanks
> >
>
> Look at what type of object HorizonatlAligment expects.  It will be
> something system.something.horizontalAligment.xlright
> chris
Author
12 Jul 2006 8:59 PM
krollenhagen
Is there a way to get vb to recognize the xlLeft, xlRight, xlCenter,
etc.. names instead of having to figure out what the corresponding
integer is?

I am having trouble getting the borders to work properly.  There are a
lot more options than left, center and right in the borders to guess
which integer corresponds to a given style, color, weight, etc...

Thank you,