View Single Post
 
Old 07-29-2022, 11:55 PM
wrdy wrdy is offline Windows XP Office 2007
Novice
 
Join Date: Jan 2014
Posts: 28
wrdy is on a distinguished road
Default Macro to convert first word of each section to Drop Caps

I have a macro that converts the first letter of the first word of each section to Drop Caps. However I would like some help editing the macro so that it will convert the whole first word to Drop Caps, rather than just the first letter. The space after the first word also needs to be deleted in order to keep the left alignment.


I have attached images showing a document before running the macro, after running the macro, and what I want the new macro to do.



Code:
Sub DropCaps()
Dim oSection As Section
Dim i As Integer
    For Each oSection In ActiveDocument.Sections
        For i = 1 To oSection.Range.Paragraphs.Count
            If Len(oSection.Range.Paragraphs(i).Range) > 1 Then
                Exit For
            End If
        Next i
        With oSection.Range.Paragraphs(i).DropCap
            .Position = wdDropNormal
            .LinesToDrop = 2
            .DistanceFromText = CentimetersToPoints(0.1)
        End With
    Next oSection
    Set oSection = Nothing
End Sub
Attached Images
File Type: png before.png (52.4 KB, 29 views)
File Type: png after.png (53.6 KB, 27 views)
File Type: png target.png (270.6 KB, 28 views)
Attached Files
File Type: docx sample text.docx (14.3 KB, 10 views)
Reply With Quote