以下不起作用。我如何添加边框?谢谢!MSACCESS VBA:将边框添加到Excel工作表
Set objApp = CreateObject("Excel.Application")
objApp.Visible = True
Set wb = objApp.Workbooks.Open("aFile.xls", True, False)
objApp.Cells.Select
objApp.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
objApp.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With objApp.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With objApp.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With objApp.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With objApp.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With objApp.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With objApp.Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Set objApp = Nothing
什么是您的错误信息还是它不工作?为什么首先选择细胞?你应该可以直接使用'objApp.cells'。 – Banjoe
没有错误消息。 objApp.Cells.Borders不起作用。 – Bruno