|

06-21-2021, 07:09 AM
|
|
Novice
|
|
Join Date: Jun 2021
Posts: 8
|
|
Macro to Formatting Text Boxes
Hi there,
I wonder if there's any possibility to create a macro that would format a larger number of text boxes even though they are grouped.
In fact, I deal with such grouped items on a daily basis, and because these are usually in large quantities, I'd like to use a macro.
What is essential for me is that the text boxes must always have these font properties (character spacing):
Scale = 100%
Spacing = Normal
Position = Normal
No Kerning for fonts
- I tried to run a macro for ungrouping them first:
Sub Ungroup()
Dim xNmbr As Integer
With ActiveDocument
For xNmbr = .Shapes.Count To 1 Step -1
.Shapes(xNmbr).Select
Set thisshape = .Shapes(xNmbr)
With thisshape.WrapFormat
.Type = wdWrapSquare
If thisshape.Type = msoGroup Then thisshape.Ungroup
End With
Next
End With
End Sub
- And then used one that should format all the (ungrouped) text boxes:
Sub SetTextBoxStyle()
Dim objTextBox As Shape
Dim objDoc As Document
Application.ScreenUpdating = False
Set objDoc = ActiveDocument
For Each objTextBox In objDoc.Shapes
' Set line style.
With objTextBox.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 255)
End With
' Set fill color.
objTextBox.Fill.ForeColor.RGB = RGB(255, 255, 255)
' Set text color.
objTextBox.TextFrame.TextRange.Font.TextColor.RGB = RGB(8, 8, 8)
' Set text size.
objTextBox.TextFrame.TextRange.Font.Size = 10
' Set font face.
objTextBox.TextFrame.TextRange.Font.Name = "Arial Narrow"
' Set character spacing.
objTextBox.TextFrame.TextRange.Font.Spacing = 0
' Set character spacing.
objTextBox.TextFrame.TextRange.Font.Scaling = 100
' Set character spacing.
objTextBox.TextFrame.TextRange.Font.Position = 0
Next objTextBox
Application.ScreenUpdating = True
End Sub
Unfortunately, this process did not entirely work; it did ungroup all the text boxes. BUT it wouldn't successfully run the second macro, most likely because an object number got too large and thus the macro failed.
Please, would you have any idea what might be the problem. Anyway, I really don't insist on running the first macro for ungrouping the textboxes, as they tend to disassemble in a quite chaotic way. I only need to set the spacing of characters in all text boxes (as quickly/easily as possible).
Thanks a lot!
Irene
|