供参考:
Sub list() Dim i As Integer, tc As Integer, mydoc As Document, myTable As Table tc = ActiveDocument.Tables.Count Set mydoc = ActiveDocument Set xlobj = CreateObject("excel.application") xlobj.Visible = True Set xlwb = xlobj.workbooks.Add With xlwb.worksheets("sheet1") For i = 1 To tc Set myTable = mydoc.Tables(i) .Cells(i, 4).Value = mydoc.Range(myTable.Cell(2, 3).Range.Start, myTable.Cell(2, 3).Range.End - 1) .Cells(i, 2).Value = mydoc.Range(myTable.Cell(5, 3).Range.Start, myTable.Cell(5, 3).Range.End - 1) If myTable.Cell(5, 3).Range.Hyperlinks.Count = 1 Then .Hyperlinks.Add Anchor:=.Cells(i, 2), Address:=myTable.Cell(5, 3).Range.Hyperlinks(1).Name .Cells(i, 3).Value = mydoc.Range(myTable.Cell(3, 3).Range.Start, myTable.Cell(3, 3).Range.End - 1) .Cells(i, 5).Value = myTable.Range.Information(wdActiveEndPageNumber) Next i End With End Sub
|