Solved

Formatting an excel cell - Borders

Posted on 2006-07-05
8
232 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

19 Experts available now in Live!

Get 1:1 Help Now