CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Help in EXCEL

  1. #1
    Guest

    Help in EXCEL

    Help! How can I draw borders in excel with visual basic? So that i can form tables...
    eg. changing the font to BOLD " excelsheet.range("A1:C1").Font.Bold = True "
    anyone can help? PLS


  2. #2
    Join Date
    Aug 1999
    Location
    Blue Springs, MO
    Posts
    43

    Re: Help in EXCEL

    The absolute best way to do this is to go to Excel, start recording a macro, and draw the borders yourself.

    Then take that code, and move it to your VB project.

    For example:

    Dim objXL as new Excel.Application
    With objXL
    .Workbooks.Add

    Range("A1:B5").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
    End With
    .Visible = true
    End With




    Hope that helps...



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured