automatic italics for quotes

FrecklePaw
2StarLounger
Posts: 130
Joined: 12 Aug 2020, 08:40

automatic italics for quotes

Post by FrecklePaw »

Is there a way that when editing after the text has been typed to add in italics for the text in quotes, e.g.

Lorem ipsum dolor sit amet, eu porro similique incorrupte sed, te aeterno diceret sea. "Vocent docendi senserit ea nec." Eum ea percipit salutandi. Ea quo inermis salutatus.

Eam nihil vituperatoribus no, "sit ut adhuc fabellas eleifend". Nonumes facilis complectitur mea no, quo dicit viderer ex. Sumo epicuri in vim. Ne sed indoctum facilisis.

I need just the text to be italicised and not the quotation marks. Is there a quick way that I can go through a whole document and amend it this way? I can have documents of several pages with lots of quotes within.

User avatar
HansV
Administrator
Posts: 78232
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: automatic italics for quotes

Post by HansV »

You can run this macro.
Warning: make sure that all quote characters " occur in pairs. If the document contains unpaired quote characters, the macro will mess things up.

Code: Select all

Sub Italicize()
    Application.ScreenUpdating = False
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .ClearFormatting
        .Text = """*"""
        .MatchWildcards = True
        Do While .Execute
            Selection.MoveStart
            Selection.MoveEnd Count:=-1
            Selection.Font.Italic = True
            Selection.Move Count:=2
        Loop
    End With
    Application.ScreenUpdating = True
End Sub
Best wishes,
Hans

FrecklePaw
2StarLounger
Posts: 130
Joined: 12 Aug 2020, 08:40

Re: automatic italics for quotes

Post by FrecklePaw »

Hi Hans, thanks. I just tried running this with, e.g.

"sit ut adhuc fabellas eleifend".

to see if it would italicise the text inside the quotes, but it didn't work and crashed. I am pairing the quotes, but I wonder if it's because I've got smart quotes turned on/off? I'm not sure which I'll check. Could this affect it making it not work?

User avatar
HansV
Administrator
Posts: 78232
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: automatic italics for quotes

Post by HansV »

I have no idea why it would crash. The macro in my previous reply works with straight quotes. If you use smart quotes:

Code: Select all

Sub Italicize()
    Application.ScreenUpdating = False
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .ClearFormatting
        .Text = ChrW(8220) & "*" & ChrW(8221)
        .MatchWildcards = True
        Do While .Execute
            Selection.MoveStart
            Selection.MoveEnd Count:=-1
            Selection.Font.Italic = True
            Selection.Move Count:=2
        Loop
    End With
    Application.ScreenUpdating = True
End Sub
Best wishes,
Hans

FrecklePaw
2StarLounger
Posts: 130
Joined: 12 Aug 2020, 08:40

Re: automatic italics for quotes

Post by FrecklePaw »

That was what was causing it - works perfectly! I always have the straight quotes option switched off. Thanks so much :)