Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Sep 2001
    Location
    Rennes, France
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Switching between smart quotes and French quotes (2003)

    Greetings fellow loungers,
    I often work on documents that are both in English and in French. When typing in French, Word recognizes the French and adjusts spelling and grammar rules accordingly. Equally, when a quote in English in my French text appears, Word makes the adjustment and recognizes the English and changes rules. However, the problem is that at the moment of switching between languages, Word doesn't know what's going on, i.e. inside a French sentence I make the move to English and open the quote with a French quotation mark (which appears as kind of like this: <<) but when I close the quote, Word now recognizes the sentence as English and closes with a normal English smart quote (this: ", in smart quote style). What I want is Word to recognize the shift back to French grammar rules and close the quote with a French quotation marker (this: >>). The only solution I can find is to select the quotation marker, switch languages and then retype it to get the right marker. Is there anything else that would make this easier?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Switching between smart quotes and French quotes (2003)

    <P ID="edit" class=small>(Edited by jscher2000 on 15-May-04 08:38. )</P>I have no experience writing in two languages, so I was not aware of this behavior. One thing you could do is re-program your " key to insert both the opening and closing quotation marks, positioning your insertion point in between. Before Word had the "Smart Quotes" feature, I had a set of macros that attached "Curly Quotes" to the key. Finding those old WordBasic macros probably is not a good use of this morning. <img src=/S/smile.gif border=0 alt=smile width=15 height=15> It's probably easier to re-create the main idea in VBA:

    <pre>Sub InsertPairedQuotMarks()
    Dim strCheckThis As String
    With Selection
    If .Type = wdSelectionIP Then
    strCheckThis = .Text
    ElseIf .Type = wdSelectionNormal Then
    strCheckThis = .Next.Text
    Else
    MsgBox "Selection type not handled: " & .Type
    Exit Sub
    End If
    Select Case strCheckThis
    Case Chr(34), Chr(148) ' English
    'Do not repeat when next character is a closing
    ' quotation mark, simply skip past it
    .MoveRight wdCharacter, 1
    Case Chr(187) 'French
    'Insert a space and then skip past
    .TypeText " "
    .MoveRight wdCharacter, 1
    Case Else
    'Insert opening and closing quotation marks and
    ' reposition between them
    If (.LanguageID = wdFrench) Or _
    (.LanguageID = wdFrenchCanadian) Then
    .TypeText Chr(171) & " " & Chr(187)
    .MoveLeft wdCharacter, 1
    Else
    .TypeText Chr(147) & Chr(148)
    .MoveLeft wdCharacter, 1
    End If
    End Select
    End With
    End Sub

    Sub Setup_BindMacroToKey()
    ' Next line is for testing; Normal.dot would be more logical
    CustomizationContext = ActiveDocument
    ' Assign macro to shifted quote mark key
    KeyBindings.Add wdKeyCategoryCommand, _
    "InsertPairedQuotMarks", _
    BuildKeyCode(wdKeyShift, wdKeySingleQuote)
    End Sub</pre>

    Give this a play, as they say, and see how it works in one of your documents.

    Added: If you are relatively new to VBA, it might not be obvious how best to test this. Here are the steps:
    1. <LI>Save the attachment to your computer in some convenient place, and change the file extension from _bas.txt "back" to .bas
      <LI>Create a new document in Word
      <LI>Press Alt+F11 to open the Visual Basic Editor. Your new document may be highlighted in the "Project Explorer" pane on the left side of the editor. If not, highlight your new document.
      <LI>Use File>Import to load the code stored in the .bas file you downloaded
      <LI>Save the document (you can do this from inside the VB Editor)
      <LI>Run the Setup... macro to attach the new code to your " key. Note that the "CustomizationContext" is limited to the test document, so this is not a global change for now.
      <LI>Close the editor and try typing text into your new document, using the " key as you normally would. What do you think?
    Attached Files Attached Files

  3. #3
    Star Lounger
    Join Date
    Sep 2001
    Location
    Rennes, France
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Switching between smart quotes and French quotes (2003)

    Jefferson,
    Wow, many thanks for this. I was plunking away with a pretty lame macro on my end after making my post but this does the trick, and many thanks for the much needed tips on getting this into VBA -- I've never worked my way through to the back of my Word manuals to really get a handle on VBA. This does the trick more efficiently than anything I was able to come up with and sure beats plunking through language selection switches all day long. I spend a lot of time lurking on the lounge and have learned a ton in the past few years. Many thanks for the time and energy you put in to this place.
    Best,
    ATL

Posting Permissions

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