谢谢甜,但不行,那不又回到设置前的了?因为只允许设置一种样式,否则就被替换为默认的
我参考附录中的“Excel与VBA”解决了。代码也不多:
Book.Save(file1) '先保存
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(file1) ‘再打开
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.Range(dr0).NumberFormat = "yyyy-mm-dd" '日期 ’设置日期格式,范围变量dr0先期赋值
Dim Rg As MSExcel.Range = Ws.UsedRange
With Rg.Borders(MSExcel.XlBordersIndex.xlInsideHorizontal) '设置被替换的水平表格线
.LineStyle = MSExcel.XlLineStyle.xlContinuous
.Weight = MSExcel.XlBorderWeight.xlThin
End With
With Rg.Borders(MSExcel.XlBordersIndex.xlInsideVertical) ‘设置被替换的垂直网格线
.LineStyle = MSExcel.XlLineStyle.xlContinuous
.Weight = MSExcel.XlBorderWeight.xlThin
End With
Wb.Save
App.Visible = True
[此贴子已经被作者于2014-7-10 19:02:32编辑过]