如何使用 vba 宏将光标到达 Publisher 2016 中文本框的末尾

how to reach curser to end of textbox in publisher 2016 with vba macro

我正在 ms publisher 中为报纸开发宏。 "grow textbox to fit text" 选项似乎不适用于下一个 linked 文本框,但我创建了一个手动技巧:

手动步骤对您来说很简单且可测试,但如果有人可以帮助我使用 vba 宏编码执行相同的步骤,那就太棒了。

我为宏目标重复步骤:

我在 vba 中成功 linking 文本框,如下所示:

    ActiveDocument.Pages(1).Shapes(1).TextFrame.NextLinkedTextFrame = ActiveDocument.Pages(1).Shapes(2).TextFrame
 ActiveDocument.Pages(1).Shapes(2).TextFrame.AutoFitText = pbTextAutoFitShrinkOnOverflow

我想制作自动报章宏

解决方法很简单:

    Dim shpTextBox As Shape

Set shpTextBox = ActiveDocument.Pages(1).Shapes.AddTextbox _
 (Orientation:=pbTextOrientationHorizontal, _
 Left:=0, Top:=0, _
 Width:=100, Height:=100)
 ActiveDocument.Pages(1).Shapes(1).TextFrame.TextRange.Text = "A Quick Brown Fox Jumps over the lazy Dog, A Quick Brown Fox Jumps over the lazy Dog, A Quick Brown Fox Jumps over the lazy Dog"




Set shpTextBox = ActiveDocument.Pages(1).Shapes.AddTextbox _
 (Orientation:=pbTextOrientationHorizontal, _
 Left:=500, Top:=500, _
 Width:=500, Height:=300)

ActiveDocument.Pages(1).Shapes(1).TextFrame.NextLinkedTextFrame = ActiveDocument.Pages(1).Shapes(2).TextFrame

ActiveDocument.Pages(1).Shapes(1).TextFrame.TextRange.Select
If Selection.Type = pbSelectionText Then

MsgBox ActiveDocument.Pages(1).Shapes(1).TextFrame.TextRange.Text


End If


ActiveDocument.Pages(1).Shapes(2).TextFrame.TextRange.Select
If Selection.Type = pbSelectionText Then

MsgBox ActiveDocument.Pages(1).Shapes(2).TextFrame.TextRange.Text



ActiveDocument.Selection.TextRange.Cut
'ActiveDocument.Pages(1).Shapes(2).TextFrame.TextRange.Cut

ActiveDocument.Pages(1).Shapes(1).TextFrame.BreakForwardLink



ActiveDocument.Pages(1).Shapes(2).TextFrame.TextRange.Paste
ActiveDocument.Pages(1).Shapes(2).TextFrame.TextRange.Select
ActiveDocument.Pages(1).Shapes(2).Width = 50

ActiveDocument.Pages(1).Shapes(2).TextFrame.AutoFitText = pbTextAutoFitGrowToFit

End If

    ActiveDocument.Pages(1).Shapes(2).TextFrame.AutoFitText = pbTextAutoFitGrowToFit