繁体   English   中英

vba 在 ms 发布者中自动调整文本框高度

[英]vba auto fit textbox height in ms publisher

如何使用 VBA启用增长文本框以适应 MS Publisher 以使用 VBA 启用增长文本框以适应 MS Publisher 2016][1]

我也有同样的问题,但在 2016 年出版商上做报纸宏的任何想法都找不到答案,想设置文本框的自动高度和固定宽度这是我的代码

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

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


 ActiveDocument.Pages(1).Shapes(1).TextFrame.NextLinkedTextFrame = ActiveDocument.Pages(1).Shapes(2).TextFrame
 ActiveDocument.Pages(1).Shapes(2).TextFrame.AutoFitText = pbTextAutoFitShrinkOnOverflow
I got it.....
it is as simple as...

    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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM