+ Reply to Thread
Results 1 to 6 of 6

VSTO Cell Alignment Enumeration

  1. #1
    Bob Sullentrup
    Guest

    VSTO Cell Alignment Enumeration

    I am right-aligning text in a cell using VSTO with this statement:

    ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;

    In VBA, it's xlRight, not -4152.

    I have discovered left justification is 1, centered is -4108;

    What do I need to include and reference to be able to say something like:

    System.Constants.Alignment.xlRight, rather than -4152?

    --
    Bob Sullentrup

  2. #2
    Vacation's Over
    Guest

    RE: VSTO Cell Alignment Enumeration

    looks like you are making 3 changes
    sheet to file
    number to text
    syntax
    = XLRight vs .XLRight

    not sure ded but this may help

    VBA version from VBE>Help

    Worksheets("Sheet1").Range("A1:A5").HorizontalAlignment = xlRight

    I'm not aware of a workbook setting so you may need to cycle through sheets

    dim wks as worksheet

    for each wks in workbook.sheets
    wks.cells().HorizontalAlignment = xlRight
    next wks

    not pretty but might get you there

    "Bob Sullentrup" wrote:

    > I am right-aligning text in a cell using VSTO with this statement:
    >
    > ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;
    >
    > In VBA, it's xlRight, not -4152.
    >
    > I have discovered left justification is 1, centered is -4108;
    >
    > What do I need to include and reference to be able to say something like:
    >
    > System.Constants.Alignment.xlRight, rather than -4152?
    >
    > --
    > Bob Sullentrup


  3. #3
    Bob Sullentrup
    Guest

    RE: VSTO Cell Alignment Enumeration

    Dear Vacation's Over:

    Not VBA, VSTO, Visual Studio Tools for Office.

    What's the C# representation?

    --
    Bob Sullentrup


    "Vacation's Over" wrote:

    > looks like you are making 3 changes
    > sheet to file
    > number to text
    > syntax
    > = XLRight vs .XLRight
    >
    > not sure ded but this may help
    >
    > VBA version from VBE>Help
    >
    > Worksheets("Sheet1").Range("A1:A5").HorizontalAlignment = xlRight
    >
    > I'm not aware of a workbook setting so you may need to cycle through sheets
    >
    > dim wks as worksheet
    >
    > for each wks in workbook.sheets
    > wks.cells().HorizontalAlignment = xlRight
    > next wks
    >
    > not pretty but might get you there
    >
    > "Bob Sullentrup" wrote:
    >
    > > I am right-aligning text in a cell using VSTO with this statement:
    > >
    > > ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;
    > >
    > > In VBA, it's xlRight, not -4152.
    > >
    > > I have discovered left justification is 1, centered is -4108;
    > >
    > > What do I need to include and reference to be able to say something like:
    > >
    > > System.Constants.Alignment.xlRight, rather than -4152?
    > >
    > > --
    > > Bob Sullentrup


  4. #4
    Vacation's Over
    Guest

    RE: VSTO Cell Alignment Enumeration

    This is generally a VBA forum

    suggest you take my Excel specifics comments to C# forum

    again there may not be a workbook wide setting for alignment
    set at cell, range or sheet level per my comments

    good luck

    "Bob Sullentrup" wrote:

    > Dear Vacation's Over:
    >
    > Not VBA, VSTO, Visual Studio Tools for Office.
    >
    > What's the C# representation?
    >
    > --
    > Bob Sullentrup
    >
    >
    > "Vacation's Over" wrote:
    >
    > > looks like you are making 3 changes
    > > sheet to file
    > > number to text
    > > syntax
    > > = XLRight vs .XLRight
    > >
    > > not sure ded but this may help
    > >
    > > VBA version from VBE>Help
    > >
    > > Worksheets("Sheet1").Range("A1:A5").HorizontalAlignment = xlRight
    > >
    > > I'm not aware of a workbook setting so you may need to cycle through sheets
    > >
    > > dim wks as worksheet
    > >
    > > for each wks in workbook.sheets
    > > wks.cells().HorizontalAlignment = xlRight
    > > next wks
    > >
    > > not pretty but might get you there
    > >
    > > "Bob Sullentrup" wrote:
    > >
    > > > I am right-aligning text in a cell using VSTO with this statement:
    > > >
    > > > ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;
    > > >
    > > > In VBA, it's xlRight, not -4152.
    > > >
    > > > I have discovered left justification is 1, centered is -4108;
    > > >
    > > > What do I need to include and reference to be able to say something like:
    > > >
    > > > System.Constants.Alignment.xlRight, rather than -4152?
    > > >
    > > > --
    > > > Bob Sullentrup


  5. #5
    Bob Sullentrup
    Guest

    RE: VSTO Cell Alignment Enumeration -- FOUND IT!

    Folks,

    Try this:

    Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;



    --
    Bob Sullentrup


    "Bob Sullentrup" wrote:

    > I am right-aligning text in a cell using VSTO with this statement:
    >
    > ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;
    >
    > In VBA, it's xlRight, not -4152.
    >
    > I have discovered left justification is 1, centered is -4108;
    >
    > What do I need to include and reference to be able to say something like:
    >
    > System.Constants.Alignment.xlRight, rather than -4152?
    >
    > --
    > Bob Sullentrup


  6. #6
    Bob Sullentrup
    Guest

    RE: VSTO Cell Alignment Enumeration

    Dear VO:

    This community is labelled "Excel Programming". Accordingly, it should
    properly encompass questions about Excel Programming, VBA or VSTO, since both
    are used for Excel programming.

    May I invite you embrace the newer technology? You'd like it if you did.

    Meanwhile, since more and more people will be upgrading, please don't
    discourage queries that emerge from the newer domains of technology.
    Understand that the VSTO context exists, and don't presume that Excel
    programming questions must emanate from the VBA domain.


    --
    Bob Sullentrup


    "Vacation's Over" wrote:

    > This is generally a VBA forum
    >
    > suggest you take my Excel specifics comments to C# forum
    >
    > again there may not be a workbook wide setting for alignment
    > set at cell, range or sheet level per my comments
    >
    > good luck
    >
    > "Bob Sullentrup" wrote:
    >
    > > Dear Vacation's Over:
    > >
    > > Not VBA, VSTO, Visual Studio Tools for Office.
    > >
    > > What's the C# representation?
    > >
    > > --
    > > Bob Sullentrup
    > >
    > >
    > > "Vacation's Over" wrote:
    > >
    > > > looks like you are making 3 changes
    > > > sheet to file
    > > > number to text
    > > > syntax
    > > > = XLRight vs .XLRight
    > > >
    > > > not sure ded but this may help
    > > >
    > > > VBA version from VBE>Help
    > > >
    > > > Worksheets("Sheet1").Range("A1:A5").HorizontalAlignment = xlRight
    > > >
    > > > I'm not aware of a workbook setting so you may need to cycle through sheets
    > > >
    > > > dim wks as worksheet
    > > >
    > > > for each wks in workbook.sheets
    > > > wks.cells().HorizontalAlignment = xlRight
    > > > next wks
    > > >
    > > > not pretty but might get you there
    > > >
    > > > "Bob Sullentrup" wrote:
    > > >
    > > > > I am right-aligning text in a cell using VSTO with this statement:
    > > > >
    > > > > ((Excel.Range)rngBackGround.Cells[7,4]).HorizontalAlignment = -4152;
    > > > >
    > > > > In VBA, it's xlRight, not -4152.
    > > > >
    > > > > I have discovered left justification is 1, centered is -4108;
    > > > >
    > > > > What do I need to include and reference to be able to say something like:
    > > > >
    > > > > System.Constants.Alignment.xlRight, rather than -4152?
    > > > >
    > > > > --
    > > > > Bob Sullentrup


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1