| 发表于:2007-11-30 11:15:37 楼主 |
该vb程序大致如下。 我绘制网格线的方法是,通过range.select选中一个区域,然后绘制这个区域的网格线。这段程序第一次运行是正常的,绘制的表格中,网格线都正确,但第二次及以后的运行中,却画不出网格,而且有时会报错误“1004,不能设置类border的linestyle属性”。我查了一下,1004的错误含义是在绘制选定区域内部的交叉线时,发现只有一行或一列,因此不存在交叉,但我这里选中的区域是"a5:d9",是多行多列。 为什么前后两次运行会有这种差异呢? '---------------------------------------------------------- dim xlappx as new excel.application dim xlbookx as new excel.workbook set xlappx = createobject("excel.application") set xlbookx = xlappx.workbooks.open(app.path & "\systemparalist.xlt") set xlbookx = xlappx.activeworkbook xlappx.application.visible = true dim xlsheet as new excel.worksheet set xlsheet = xlbookx.sheets(2) xlsheet.select xlsheet.range("a5:d9").select selection.borders(xldiagonaldown).linestyle = xlnone selection.borders(xldiagonalup).linestyle = xlnone with selection.borders(xledgeleft) .linestyle = xlcontinuous .weight = xlthick .colorindex = xlautomatic end with with selection.borders(xledgetop) .linestyle = xlcontinuous .weight = xlthick .colorindex = xlautomatic end with with selection.borders(xledgebottom) .linestyle = xlcontinuous .weight = xlthick .colorindex = xlautomatic end with with selection.borders(xledgeright) .linestyle = xlcontinuous .weight = xlthick .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 '--------- < set xlsheet = nothing xlappx.application.visible = true set xlbookx = nothing set xlappx = nothing |
|
|
|
|