Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smart apostrophes and quotation marks (Word 2002 SP 2)

    Is there a simple way to replace standard apostrophes and quotation marks with "smart" ones in a Word document? I see that typing these causes an auto-replace to take place, but what about apostrophes and quotation marks which are already in the document? For example, text which I have pasted into a document from elsewhere often has apostrophes and quotation marks which are not "smart." Ideally, I'd like to be able to add a button to the toolbar that, when clicked, would search and replace all standard apostrophes and quotation marks with smart ones. Any suggestions? Many thanks in advance for any help.
    regards,
    Abraham Z.

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

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    Manually: replace double quotes by double quotes and single quotes by single quotes. If smart quotes are on, straight quotes will be replaced by smart ones.

    Macro (can be assigned to a toolbar button and/or keyboard shortcut):

    Sub ReplaceQuotes()
    With ActiveDocument.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .MatchWildcards = False
    .MatchWholeWord = False
    .Execute FindText:=Chr(34), ReplaceWith:=Chr(34), Replace:=wdReplaceAll
    .Execute FindText:=Chr(39), ReplaceWith:=Chr(39), Replace:=wdReplaceAll
    End With
    End Sub

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    Great! This is just what I was hoping for.

    Sorry to be dense, but can you tell me what to do with the macro text you provided? I went to the Macro editor but I couldn't figure out where to put the text, or how to define the macro, or how to add it to the toolbar? Many many thanks,
    Abraham Z.

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

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    1. Create the macro:

    Select Tools | Macro | Macros...
    Type ReplaceQuotes into the Macro Name box.
    Click Create.
    This will activate the Visual Basic Editor, create a new module in Normal.dot (the default template), and create the first and last line of the macro, with some comments (starting with an apostrophe). You can delete the comment lines.

    Sub ReplaceQuotes()

    End Sub

    Copy the lines between Sub and End Sub from the code I posted , and paste them into the macr, so that it looks as it does in my post.
    Press Alt+F4 to close the Visual Basic Editor.

    2. Assign to a toolbar button:

    Select Tools | Customize...
    Activate the Commands tab (if necessary)
    Select Macros in the list of Categories on the left hand side.
    Select ReplaceQuotes in the list of Commands on the right hand side.
    Drag this item to one of the toolbars and drop it there. You can drag it to another location if you like.
    Right-click the new toolbar button to edit the name of the button, and to select or edit the button picture.
    When you are done, click Close in the Customize dialog.

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Smart apostrophes and quotation marks (Word 20

    Hi Abraham:
    First, in order for this macro to work for you, make sure that you have Tools/AutoCorrect.../Autoformat as you type tab/Replace as you type/straight quotes with smart quotes.

    Secondly, see <post#=21373>post 21373</post#> for instructions as to how to create this macro with the code provided.
    Cheers,

  6. #6
    Star Lounger
    Join Date
    Jan 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    Hans,

    Perfect! Many thanks, this does exactly what I was hoping. I appreciate the help.
    Abraham Z.

  7. #7
    Star Lounger
    Join Date
    Jan 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    A few days ago I posted about wanting to create a macro to automatically replace straight quote marks with smart ones and got a great response from HansV (see above). Now I'm wondering if I can modify the same macro to make it do the same thing but for the dash mark. It seems that it should be the same idea, but when I look at the macro text (see above), I can't see what to change. Any suggestions?
    Many thanks in advance,
    Abraham Z.

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

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    Dashes work a bit differently; replacing a dash by itself won't activate the AutoCorrect mechanism. So you must explicitly replace the normal dash by the n-dash character. Assuming that you only want to do this if the dash is preceded and followed by a space, this variation on the earlier macro should do it:

    Sub ReplaceDashes()
    With ActiveDocument.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .MatchWildcards = False
    .MatchWholeWord = False
    .Execute FindText:=Chr(32) & Chr(45) & Chr(32), _
    ReplaceWith:=Chr(32) & Chr(150) & Chr(32), _
    Replace:=wdReplaceAll
    End With
    End Sub

  9. #9
    Star Lounger
    Join Date
    Jan 2003
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Smart apostrophes and quotation marks (Word 2002 SP 2)

    Works perfectly! Many thanks again.
    Abraham

Posting Permissions

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