Macro For Drop Cap

G

Guest

How would you select the first character and format it as a drop cap. This
need to be automated in a macro and I don't know how to record this.
 
G

Guest

Jay,

When you say the "first character," do you mean in the file, in every single
paragraph, or on every page (or section)?

If you really wanted to put a drop cap in EVERY single paragraph in the
active (open) document, including headings, etc., then this macro will do the
job. Maybe this can at least get you started.

Thanks,
Ben

Sub DropCapOnEveryParagraph()
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
' if the paragraph is empty, don't do anything (i.e. character.count=1)
If oPara.Range.Characters.Count > 1 Then
With oPara.DropCap
.Position = wdDropNormal ' other choices are wdDropNone and
wdDropMargin
.FontName = "Times New Roman" ' or whatever you want
.LinesToDrop = 3
.DistanceFromText = InchesToPoints(0)
End With
End If
Next oPara
 
G

Graham Mayor

You don't need a macro. The drop cap function is available in Word - on the
format menu in Word 2003, on the Insert Tab in Word 2007.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Thanks for your help. Unfortunately I'm getting an error that says "invalid
use of property" for the line containing "wdDropMargin". Any ideas? Also, I
just want to do the first paragraph after the title. Thanks again.
 
G

Guest

I realize that I don't need a macro, but, I would like to automate it with a
macro. I would like the first paragraph after the title to have a drop cap in
many documents so I would like a macro to do that. Thanks,
-Jay
 
R

Robert M. Franz (RMF)

Hi Jay

jay_2882 said:
Thanks for your help. Unfortunately I'm getting an error that says "invalid
use of property" for the line containing "wdDropMargin". Any ideas? Also, I
just want to do the first paragraph after the title. Thanks again.

it seems Ben's newsreader (rightly :)) split the line there
(wdDropMargin is supposed to be on the line above). But everything after
the ' is a comment, anyway, so you can safely delete it.

However, you say you want each paragraph after a "title" to have a
DropCap? If you use Heading 1 as a title, the following macro (with Help
from Helmut Weber) should do:

Sub DropCapAfterHeading1()

Dim myPara As Word.Paragraph

If ActiveDocument.Paragraphs.Count > 1 Then
For Each myPara In ActiveDocument.Paragraphs
If myPara.Style = ActiveDocument.Styles(wdStyleHeading1) Then
With myPara.Next
If .Style <> ActiveDocument.Styles(wdStyleHeading2) Then
With .DropCap
.Position = wdDropNormal
.FontName = "+Body"
.LinesToDrop = 3
.DistanceFromText = CentimetersToPoints(0)
End With
End If
End With
End If
Next myPara
End If
End Sub

Watch out for further line breaks (which will happen). The macro does a
tiny bit more, in that it looks at the paragraph following a "Heading 1"
and only adds a drop cap if the style is _not_ "Heading 2". I have no
idea what happens if the first "thing" after a "Heading 1" is a table, a
picture, etc. Does not seem all too likely to test (as unlikely as the
very last paragraph of the document being in "Heading 1", because the
code will probably fail then).

HTH
Robert
 
G

Graham Mayor

Working on the premise that your titles (and only your titles) are formatted
with the paragraph style Heading 1 the following macro will apply a drop cap
to the next letter.

Sub AddDropCap()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Style = "Heading 1"
Do While .Execute(findText:="", _
MatchWildcards:=False, Format:=True, Wrap:=wdFindStop, _
Forward:=True) = True
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
With Selection.Paragraphs(1).DropCap
.Position = wdDropNormal
.LinesToDrop = 3
.DistanceFromText = CentimetersToPoints(0)
End With
Selection.MoveDown
Loop
End With
End Sub

If necessary apply a unique style to your Chapter headings and modify the
macro to use that style in place of Heading 1

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Break column with Drop Cap character 2
Drop Cap 1
Drop cap style 3
How do I add a drop cap in text contained in a text box? 2
Drop Cap Option Greyed 10
Drop Cap Option Greyed Out 13
drop cap problems 1
Drop Cap 2

Top