2,462
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Public Sub test()
Dim objRange As Range
Set objRange = ActiveDocument.Tables(1).Cell(1, 1).Range ' Tabels(1)表示文档中的第一个表格Cell(1,1)为第1行第1列,可自行调整;
objRange.Select
Selection.MoveRight wdCharacter, 1
Selection.MoveLeft wdCharacter, 1
Do
Dim dblTop As Double
dblTop = Selection.Information(wdVerticalPositionRelativeToPage)
If dblTop < 108 Then ' 自己调整,能显示的最后一行距页面顶端的高度;
Exit Do
End If
Selection.MoveLeft wdCharacter, 1, wdExtend
Loop
Selection.MoveRight wdCharacter, 1, wdExtend
Dim strContent As String
strContent = Selection.Text
Selection.Text = ""
ActiveDocument.Tables(2).Cell(1, 1).Select ' 选中目标单元格,可自行调整;
Selection.Text = strContent
MsgBox Selection.Information(wdVerticalPositionRelativeToPage)
End Sub
dim objRange as range
set objRange = ... ' 第一页的包含超出表格内容的对象;
dim strContent as string
strContent = objRange.Text
dim objRange2 as Range
set objRange2 = ... ' 第二页填写超出表格内容的对象;
Const MaxLen as long = 500 ' 超过500个字符就分页,可根据情况自行调整;
if len(strContent) > maxlen then
objrange.text = left(strcontent,maxlen)
objrange2.text = mid(strcontent,maxlen+1)
end if