我们有时必须在工作中填写一组表格,我试图通过让 excel VBA 将表格重新创建为 word 文档并填充适当的数据并打印为 pdf 来自动完成任务。我被困在删除边框线样式上。我希望左侧没有边界线。我尝试了不同的方法,根据我的理解,最有可能起作用的方法如下:(注意:“.Border(xlEdgeleft).LineStyle = xlLineStyleNone”是给我带来麻烦的行)
Sub main()
Dim objWord As Object
Dim objDoc As Object
Dim objHdrRange As Object
Dim myTable As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
Set objHdrRange = objDoc.Sections(1).headers(1).Range
Set myTable = objWord.activedocument.tables.Add(objHdrRange, 5, 5)
With myTable
.Borders.enable = True
.Border(xlEdgeleft).LineStyle = xlLineStyleNone
‘more code goes here later
End With
Set objDoc = Nothing
Set objHdrRange = Nothing
objWord.Quit
End Sub