vb6调用excel时如何绘制边框
我已能将mshflexgrid中的数据导入到excel中,请问如何给数据绘制网格状边框,使其打印更美观...
我已能将mshflexgrid中的数据导入到excel中,请问如何给数据绘制网格状边框,使其打印更美观
展开
展开全部
我随便录制了一段宏,你一看肯定就明白了
Sub Macro1()
Range("B2:F12").Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End Sub
这里的Range(...),Selection都是WorkSheet的子对象,而WorkSheet又是Workbook的子对象,我想你应该是知道的,还有那些常数,你可以在Excel的VBA编辑器里用Print 常数名称 看到他们真正的数值
Sub Macro1()
Range("B2:F12").Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End Sub
这里的Range(...),Selection都是WorkSheet的子对象,而WorkSheet又是Workbook的子对象,我想你应该是知道的,还有那些常数,你可以在Excel的VBA编辑器里用Print 常数名称 看到他们真正的数值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询