Solved

Formatting an excel cell - Borders

Posted on 2006-07-05
8
233 Views
Last Modified: 2010-04-23
Friends,

I need to put a border around each individual cell that I am including in a spreadsheet      The Range includes A1 through O22

So, I guess what I'm asking is what would the property setting (syntax) be?

Here is my code that accompanies it:

 With oSheet.Range("A1", "O" & NumberOfCarsInRace + 3)

            .VerticalAlignment = excel.XlVAlign.xlVAlignCenter
            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter

            '.Borders.Application.????????????????
0
Comment
Question by:indy500fan
  • 4
  • 4
8 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17045526
With oSheet.Range("A1", "O" & NumberOfCarsInRace + 3)
         .VerticalAlignment = excel.XlVAlign.xlVAlignCenter
         .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter

    With .Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With .Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
  End With
0
 

Author Comment

by:indy500fan
ID: 17045580
I'm getting errors with the xl* items.  Is there something I need to declare that I'm not?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045621
I now see that you are in VB.net.

as I don't have VB.net handy, you will have to find the correct syntax, it will be similar to this:
xlContinuous  should be excel.XlLineStyle.xlLineStyleContinuous
etc
0
 

Author Comment

by:indy500fan
ID: 17045715
??? Actually, I need help with that.  

As you said excel.XlLineStyle.xlLineStyleContinuous works, but I can't make the

With .Borders(xlEdgeBottom) work.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045753
xlEdgeBottom - > excel.XlBordersIndex.xlEdgeBottom
xlThin -> excel.XlBorderWeight.xlThin
xlAutomatic ->  Excel.XlColorIndex.xlColorIndexAutomatic
0
 

Author Comment

by:indy500fan
ID: 17045799
AngelIII,

Okay, that compiled, thanks for that; however, it puts a border around the whole set rather than each cell as I requested.  Any other suggestions?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045821
indeed, I forgot to copy 2 blocks:

    With .Borders(excel.XlBordersIndex.xlInsideVertical)
        .LineStyle = excel.XlLineStyle.xlContinuous
        .Weight = excel.XlBorderWeight.xlThin
        .ColorIndex = Excel.XlColorIndex.xlAutomatic
    End With
    With .Borders(excel.XlBordersIndex.xlInsideHorizontal)
        .LineStyle = excel.XlLineStyle.xlContinuous
        .Weight = excel.XlBorderWeight.xlThin
        .ColorIndex = Excel.XlColorIndex.xlAutomatic
    End With
0
 

Author Comment

by:indy500fan
ID: 17045907
angellIII,

Brilliant!  That works.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now