我正在尝试使用以下代码确定当前迭代表的页码:
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
tableNo = wdDoc.tables.Count
tableTot = wdDoc.tables.Count
If tableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
ElseIf tableNo > 1 Then
tableNo = InputBox("This Word document contains " & tableNo & " tables." & vbCrLf & _
"Enter the table to start from", "Import Word Table", tableNo)
End If
resultRow = 4
For tableStart = 1 To tableTot
With .tables(tableStart)
'copy cell contents from Word table cells to Excel cells
For iRow = 1 To .Rows.Count
For iCol = 1 To .Columns.Count
Cells(resultRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
Cells(resultRow, 4) = pageNumber
resultRow = resultRow + 1
Next iRow
End With
resultRow = resultRow + 1
Next tableStart
End With
我正在研究一种方法,发现了这一点
oTable.Range.Information(wdActiveEndPageNumber)
我尝试通过使用它
pageNumber = .Range.Information(wdActiveEndPageNumber)
,但是显然它不起作用,因为im并没有真正遍历activeobject。它基本上是:
wdDoc.tables(1-N).Range.Information(wdActiveEndPageNumber);
不起作用,wdActiveEndPageNumber上的错误,
是否可以获取页码?