|
- Sub xlinsetwd()
- Dim tableNew As Table
- Dim aRow, Num As Integer
- Dim arr, i%, xlApp As New Excel.Application
- Application.ScreenUpdating = False
- xlApp.workbooks.Open ThisDocument.Path & "\报价.xlsx"
- arr = workbooks("报价.xlsx").worksheets(1).Range("A1").CurrentRegion
- workbooks("报价.xlsx").Close False
- xlApp.Quit
- Set tableNew = Selection.Tables(1)
- If Selection.Information(wdWithInTable) = True Then '判断是否选中表格
- MsgBox "我在表格第 " & .Information(wdStartOfRangeRowNumber) & " 行,第 " & .Information(wdStartOfRangeColumnNumber) & " 列"
- With tableNew
- For i = 1 To UBound(arr)
- .Cell(i, 8).VerticalAlignment = wdCellAlignVerticalCenter
- .Cell(i, 8).Range.Delete
- .Cell(i, 8).Range.Text = arr(i, 8) '将数组中第8列写入指定位置
- .Cell(i, 9).Range.Delete
- .Cell(i, 9).VerticalAlignment = wdCellAlignVerticalCenter
- .Cell(i, 9).Range.InsertAfter "6%" '将数组中第9列写入指定位置
- Next
- End With
- End If
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|