Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Adding a border in Excel using VB.NET

Adding a border in Excel using VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nvmoss
    wrote on last edited by
    #1

    I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss

    J N 2 Replies Last reply
    0
    • N nvmoss

      I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss

      J Offline
      J Offline
      John Kuhn
      wrote on last edited by
      #2

      Of course, you already know about adding the Excel library as a reference to your project. After that, adding a border should be easy:

      Dim xl As New Excel.Application
      xl.Workbooks.Open("c:\000\book1.xls")
      With xl.Range("Data").Borders(Excel.XlBordersIndex.xlEdgeBottom)
      .LineStyle = Excel.XlLineStyle.xlContinuous
      .Weight = Excel.XlBorderWeight.xlThin
      .ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
      End With
      xl.ActiveWorkbook.Save()
      xl.Workbooks.Close()

      What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

      1 Reply Last reply
      0
      • N nvmoss

        I am trying to add a border to the bottom of a range in Excel. It is easy to add a border on all four sides using the BordersAround Method, but I can't figure out how to add a border to the bottom of the cell only. Can any one tell me how to do this? Thanks! nvmoss

        N Offline
        N Offline
        Nick Seng
        wrote on last edited by
        #3

        Here's the secret to coding Excel with VBA. Use the Macro Recorder.


        "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone It's a weird Life

        J 1 Reply Last reply
        0
        • N Nick Seng

          Here's the secret to coding Excel with VBA. Use the Macro Recorder.


          "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone It's a weird Life

          J Offline
          J Offline
          John Kuhn
          wrote on last edited by
          #4

          Right on, Nick. :cool: What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups