Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Duplicating Ignore All in a Macro (Word 2003)

    I have been trying to incorporate in some of my macros language to have Word ignore all instances of a selected word. A search through Word VBA help gave me the following language:

    Selection.NoProofing = True

    but it doesn't do the job and I haven't been able to find anything else. What I am trying to do is duplicate the effect of coming to a word that has been marked as incorrectly spelled by Word (with the red squiggle underline), right-clicking to bring up the context menu, and choosing from that menu Ignore All. When you choose Ignore All, the red squiggle disappears from all instances of the word in the document and Word no longer sees it as misspelled.

    Does anyone have a suggestion? Thanks.

  2. #2
    Star Lounger
    Join Date
    Jul 2006
    Location
    Colorado, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    One possible kludge: have Word do a search and replace on found mispelled word and have it add a number to it. If you have Word spell check set to ignore words with numbers, it will ignore the rest. When done, have a search and destroy for the number added. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Another option would be to search for all instances of the currently selected word and set the language to No-Proofing.

    StuartR

  4. #4
    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: Duplicating Ignore All in a Macro (Word 2003)

    Through querying the controls of CommandBar("Spelling") under various circumstances, I was able to isolate the control you need:

    <pre>Sub IgnoreAll()
    ' Execute the Ignore All command bar control w/r/t the
    ' word at the insertion point
    On Error Resume Next ' fails if not misspelled
    CommandBars.FindControl(ID:=2796).Execute
    On Error GoTo 0 ' reset error handling
    End Sub</pre>


    Does that help in your application?

  5. #5
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Thank you. The language does work perfectly with all but one of my macros for which I needed the solution. I delayed responding with a thanks to see if I could work out the problem with the one macro, but I can't. So I hope someone will be able to help with this last step.

    The language you provided works perfectly as long as I haven't selected text. For example, in the normal course of events, if the word I wanted ignored was "clillxy", just having my cursor in the word does the job and allows me to proceed to with the remainder of my macro functions. But where it doesn't work is if I need to select only a portion of the word/phrase. For example, if the word in the text is CXFs and I need it to ignore only CXF, I can't select just CXF. The language you gave me insists on deselecting my selection and running Ignore All against the whole word. I grant that this is exactly how Ignore All works, which is what I asked for, but I had thought perhaps I could get around that Ignore All limitation.

    If I can't make a workaround, I'll live with it because this is a major improvement. BTW, I do realize that in the example I gave (CXFs), I could easily add a space between the F and s, but not all instances have the single letter to be ignored. The reason I need the CXF portion only, is that I want only the root indicated as OK so that I am certain to catch variances from the root. If it marks only the variation of the root with Ignore All, then all subsequent instances of the root will show as incorrect . For example, if CXFs is marked Ignore All, it might appear in that form only 3 times in a 100-page document but 50 times as CXF and 4 times as CXFing. I should add that this particular macro in which this is a problem highlights the selection in color throughout the document so that I know I have checked the word/phrase. (I hope I have been clear.)

    In case it will help, here is the problem macro in its original form:

    ' Marks all instances of selected text with highlight
    ' to end of document

    ' Check that user has selected some text

    If Not Selection.Type = wdSelectionNormal Then
    MsgBox "Please select some text.", vbInformation
    Exit Sub
    End If

    ' Establishes selected text as the F&R text

    Dim strText As String
    strText = Selection.Text

    ' Inserts bookmark where process begins
    ActiveDocument.Bookmarks.Add "MarkReturn", Selection.Range

    ' Clears formatting and turns highlighting on
    ' Searches for exact match of selected text

    With Selection.Find
    .ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Text = strText
    .MatchCase = True
    .Execute

    ' Repeats macro until selected text no longer found

    Do While .Found = True
    intFindCounter = intFindCounter + 1
    Selection.Range.HighlightColorIndex = wdYellow
    .Execute
    Loop

    ' Deselects last instance and returns cursor to start point

    Selection.Collapse Direction:=wdCollapseEnd
    Selection.GoTo What:=wdGoToBookmark, _
    Name:="MarkReturn"
    End With

    ' Deselects original text and moves cursor to
    ' position immediately following the F&R text

    Selection.Collapse Direction:=wdCollapseEnd

    End Sub

  6. #6
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Thanks, Stuart, but that will slow the process significantly considering that the documents I work with are very long and riddled with technical words and acronyms that need to be added to custom dictionaries or marked.

  7. #7
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Thanks, pi. I hadn't thought of that solution. Alas, it won't work for the reason that I gave Stuart for his suggestion.

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Rich,

    It takes no time at all, I use this macro all the time, it is attached to a toolbar button so that I just select the word with the wavy red underline and then click the button, total time taken in a document with many hundreds of pages is not detectable. I include a bit of extra checking so that it only searches when you have a small amount of text selected.

    StuartR

    <code>
    Public Sub NoProofing()
    Dim txtOriginal As String

    txtOriginal = Trim(Selection.Range.Text)

    If txtOriginal <> "" Then
    Selection.LanguageID = wdNoProofing
    If Selection.Words.Count < 4 Or Selection.Characters.Count < 25 Then
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.LanguageID = wdNoProofing
    .Text = txtOriginal
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = True
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    .Replacement.ClearFormatting
    End With
    End If
    End If
    End Sub
    </code>

  9. #9
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Thanks, Stuart. I just tried it (of course, I shoudl have read the macro first, but when in a hurry <img src=/S/smile.gif border=0 alt=smile width=15 height=15> ). With some modification for my particular needs, I think your solution will work for my highlighting macro. I appreciate the quick response.

  10. #10
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    Stuart, a special thanks <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> to you and a dunderhead to me <img src=/S/bash.gif border=0 alt=bash width=35 height=39> . I just read your code and realized that what I needed was a single line added to my macro: Selection.Range.LanguageID = wdNoProofing. I added the line to the Do While section (see below) and now the macro does exactly what I need. Now if the lightbulb would only light more often <img src=/S/smile.gif border=0 alt=smile width=15 height=15>. Again, thanks for turning on the light!

    Do While .Found = True
    intFindCounter = intFindCounter + 1
    Selection.Range.HighlightColorIndex = wdYellow
    Selection.Range.LanguageID = wdNoProofing
    .Execute
    Loop

  11. #11
    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: Duplicating Ignore All in a Macro (Word 2003)

    Rich, I'm not sure I fully grasp the issues here. If you are equally happy with the more permanent solution of marking text with the "No Proofing" attribute, then I won't work on this any further.

  12. #12
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    I apologize for not being clear. Let me try to explain the issue again. In my document I come across the following text (a made up example): "Although multiple congestive heart failures (CHFs) seem less likely to occur than a single CHF . . . " Word sees both CHFs and CHF as incorrect and marks them so with the squiggle. However, I know that CHF is the correct acronym for congestive heart failure so I want to, at its first use, mark CHF -- but not CHFs -- with highlight so that when I come across CHF 3 pages from now, I can visually see that the acronym has already been defined in the document. The marking with highlight tells me that I've determined that the acronym is correct. And I want CHF to be marke with Ignore All so that Word won't continue to indicate that CHF is a misspelling, which reduces the risk of Word telling me there are too many misspellings in the document and giving me a second indicator that CHF is OK.

    With your suggestion, I cannot select only CHF; in fact, I can't select anything. The language you provided automatically sets CHFs to Ignore All, but only if nothing is selected. It requires that the cursor simply be in the word to which Ignore All is to be applied. The problem is that if Word applies Ignore All to CHFs, CHF still appears as misspelled.

    As a result of Stuart's suggested macro setting off a lightbulb in my head, I added only the 1 line to my Highlight macro and it appears to work. Whether it is the best solution, I do not know. Your suggested language was added to the other macros for which this was a problem because in their cases, it is the whole word to which Ignore All needs to be applied (e.g., when adding a word to a custom dictionary other than the default Custom Dictionary) -- I do not need to select a portion. Because I believe the Highlight macro will work as I need, I would not want you to devote time to solving a problem that appears to no longer exist. I really won't know whether it works as I need until I put it to the real test in my daily work. If it doesn't, I'll be back if I can't figure out how to fix it myself, starting from the material you and Stuart have provided. Again, thanks.

  13. #13
    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: Duplicating Ignore All in a Macro (Word 2003)

    I see now. Even if it were possible to "Ignore All" for CHF, that would not help because Word will mark as unrecognized all of the variations of CHF, since spell-check is performed on whole words.

  14. #14
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating Ignore All in a Macro (Word 2003)

    As a followup, I have been using my macros with the modifications suggested. I only had to make one small additional tweak in one macro. Aside from that tweak the macros work perfectly with the suggestions you provided and do exactly what I need. Again, thank <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> you all for your help.

Posting Permissions

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