以下不起作用。我如何添加邊框?謝謝!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