Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-21-2021, 07:09 AM
effimera effimera is offline Macro to Formatting Text Boxes Windows 10 Macro to Formatting Text Boxes Office 2019
Novice
Macro to Formatting Text Boxes
 
Join Date: Jun 2021
Posts: 8
effimera is on a distinguished road
Default 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
Reply With Quote
 

Tags
character spacing, font formatting macro, textboxes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Formatting Text Boxes formatting photos within text boxes ianmck Drawing and Graphics 5 06-28-2018 09:04 PM
Macro to insert different sets of text at bookmark depending on sequence of selected check boxes chipper09 Word VBA 0 06-21-2018 01:49 PM
Macro to Formatting Text Boxes Drawing lines between text boxes which have actual text within the text boxes RHODIUM Word 6 10-01-2016 04:43 PM
Macro to Formatting Text Boxes Is there a way to anchor drop-down content control boxes so entering text doesn't change formatting? TzarChasm Word 7 04-14-2016 06:28 PM
Macro (or something) to run Spell Check within rich text content boxes in lock document NMBELL Word 8 12-21-2015 04:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft