PDA

View Full Version : Publisher text box not changing all the font



Agent Smith
08-12-2021, 10:50 AM
When creating a text box in publisher (form access) I noticed when trying to change the font and size, only some of the text changed. I had to put a for loop in to run the code a few times and this seems to work. Does anyone know it doesn't work fully on the first pass?


Set ShpTB = DocPub.Pages(2).Shapes.AddTextbox _(Orientation:=pbTextOrientationHorizontal, _
Left:=122, Top:=702.8, _
Width:=horzwidth, Height:=55)
DocPub.Pages(2).Shapes("Text Box " & 1).TextFrame.TextRange.Text = exceptiontext


With ShpTB
For x = 1 To 25 'need to repeat this as doesn't change all text unless repeated for some reason
.TextFrame.TextRange.Font.Size = 8
.TextFrame.TextRange.Font.Name = "Tahoma"
Next x
End With

Gasman
08-13-2021, 06:56 AM
Well a quick Google seems to confirm what I thought how it should work?
You need to select the text first?
https://docs.microsoft.com/en-us/office/vba/api/publisher.textrange.font