|
楼主 |
发表于 2016-12-22 20:26
|
显示全部楼层
Sub 插入索引页码()
Dim c As Cell
Application.ScreenUpdating = False
myNums = ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
For n = 1 To UBound(myNums)
If InStr(LCase$(myNums(n)), "项目1") Then
With Selection.Tables(1).Range.Columns(8)
For i = 2 To .Cells.Count
.Cells(i).Range.Delete
With .Cells(i).Range
.InsertAfter "第页": .Collapse 0: .End = .End - 2
.InsertCrossReference 0, 7, n + i - 2, True
End With
Next
End With
Application.ScreenUpdating = True
MsgBox "交叉引用插入完毕!"
Exit Sub
End If
Next n
MsgBox "无法找到编号项!"
End Sub
问题已经解决,重新设置Range.Collapse方法和Range.End 属性即可 |
|