Hi MS Publisher VBA programmers :-)
What seems so simple is actually not documented. All I need to do is be able to insert text programmatically into a text box then have the text resize vertically expanding itself as I add more text.
This works fine if I do it manually by inserting TextBox and choosing the "Grow Text Box To Fit" option in the Text Fit drop-down in the Format tab of the TextBox.
This code doesn't work:
Sub myGrowToFit()
Set myTextBox = ActiveDocument.Pages(1).Shapes.AddTextbox _
(Orientation:=pbTextOrientationHorizontal, _
Left:=0, Top:=0, _
Width:=100, Height:=40)
myTextBox.TextFrame.TextRange.text = "Line1" & vbLf & "Line2" & vbLf & "Line3" & vbLf & "Line4"
myTextBox.TextFrame.AutoFitText = pbTextAutoFitGrowToFit
MsgBox ("Press OK to Continue After You View The Result")
myTextBox.Delete
End Sub
Any ideas? Thanks.