请教关于 word2007 vba 问题,忘帮忙解答,谢谢

word vba的代码,设置边框的,在2003里面能够正常使用,如下:
With Selection.Cells
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
,在word2007中出现错误,错误提示为: 集合所要求的成员不存在,发生错误的地点就在
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone这两行,有大神能帮忙解答一下吗?应该如何修改?

    你是在test.xslm中写代码还是在另外一个工作簿中写代码。在本工作簿中可去掉dim  Myxls  as object及下面一句。如果在其他工作簿中写代码是不能运行的。
    应该改为:Dim Myxls As Object
    Dim xlBook As Excel.Workbook
    Dim xlsheet As Excel.Worksheet
    Set  Myxls= CreateObject("Excel.Application")
    Myxls.Visible = false
    Set  xlBook = Myxls.Workbooks.Open("你的文件路径")
    Set  xlSheet = xlBook.Worksheets(1)
    xlsteet.range("A65536").End(xlUp).Row
    再后面的代码相应改改,应该不会有问题,应因怎我也经常用VBA给公司做应用的。

温馨提示:答案为网友推荐,仅供参考
相似回答