January 11th, 2000, 06:34 AM
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
rockies1
January 11th, 2000, 08:06 AM
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...