Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to Italize Text (MS Word 2003)

    Can someone help me with this macro, please? It works fine the first time, however, if I do not realize that I already have run it, it takes away the italize, which is not what I want.

    I would like the macro to check if the text is already italized, do not run the macro. If the text is not italized, then run the macro. The quotes are curly quotes.


    Sub Quot_Ital_Chg()
    '
    ' Makes text between quotes italic
    ' Macro recorded 10/21/2005 by Maria V. Garrido
    ' Attached to ALT+8
    '
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = ChrW(8220)
    .Replacement.Text = ""
    .Forward = True
    End With
    Selection.Find.Execute
    Selection.Extend
    Selection.Extend Character:=ChrW(8221)
    Application.Run MacroName:="Normal.NewMacros.Italic"
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Application.Run MacroName:="Normal.NewMacros.Italic"
    End Sub

    Thank you so very much.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Italize Text (MS Word 2003)

    I don't know what your macro Normal.NewMacros.Italic does, so here is a version that uses the built-in Italic property:

    Sub Quot_Ital_Chg()
    '
    ' Makes text between quotes italic
    ' Macro recorded 10/21/2005 by Maria V. Garrido
    ' Attached to ALT+8
    '
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ChrW(8220) & "*" & ChrW(8221)
    .MatchWildcards = True
    .Forward = True
    If .Execute Then
    Selection.MoveStart
    Selection.MoveEnd Count:=-1
    If Selection.Font.Italic = False Then
    Selection.Font.Italic = True
    End If
    End If
    End With
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Thank you. It works beautifully.

  4. #4
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Italize Text (MS Word 2003)

    This macro has saved me hours of work. However, could you please tell me how to "turn off" the wildcards after it has done the search? Thank you so much.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Immediately above the line End With, insert a new line

    .MatchWildCards = False

  6. #6
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Thank you, but even though I did as you said, it does not work. When I use CTRL+F to find something else the "Use wildcards" is still on.

    Here is the macro:

    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ChrW(8220) & "*" & ChrW(8221)
    .MatchWildcards = True
    .Forward = True

    If .Execute Then
    Selection.MoveStart Count:=-1
    Selection.MoveEnd

    If Selection.Font.Italic = False Then
    Selection.Font.Italic = True

    End If
    End If

    .MatchWildcards = False

    End With
    End Sub

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Sorry, I can't explain that. It works correctly for me. I'm using Word 2002, I'll try on Word 2003 tomorrow.

  8. #8
    Lounger
    Join Date
    Jul 2003
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Does capitalization matter? Because yours is different from Hans'.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Sorry, what do you mean?

  10. #10
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macro to Italize Text (MS Word 2003)

    The capitalisation doesn't matter - Word will adjust it automatically anyway.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Italize Text (MS Word 2003)

    I just now tried it in Word 2003 SP1. "Use wildcards" is off after running the macro, so I'm afraid I have no solution for you.

  12. #12
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Italize Text (MS Word 2003)

    Thank you anyway. The macro has helped me a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •