none
Word 2013 CRASHES on Range.find.Execute RRS feed

  • Question

  • Word 2013 crashes if you invoke range.find.execute with tables having merges cells.

    Create a 3x3 table in word document and merge last 2 cells of 3rd column
    i.e cells C(row=2, col=3) & C(row=3, col=3)

    In Cell(row=3, col=2) , write text "test". So resulting table would look like

    ________________________
    ________|_______|________|
    ________|_______|                |
    ________|__test__|________|

    Now invoke this macro:

    Dim rng As range

    'Use any of these range setter
    'Set rng = ActiveDocument.range(0, 0)
    'Set rng = ActiveDocument.Tables(1).range
    Set rng = ActiveDocument.Content

    With rng.Find
        .Forward = True
        .Wrap = wdFindContinue
        .Execute "test"
    End With

    Result : CRASH !!. While selection.find.execute doesn't crash.

    Is there any workaround for this other than selection.find.execute? What does word use natively for find-replace functionality?

    Regards,
    Rahul

    Tuesday, April 15, 2014 6:56 AM

Answers

  • Hi Rahul,

    Did you want to search the words in a specific range? If so, as a workaround you can select the specific range, then use the selection to search. Here is a sample for your reference:

    Sub FindInTable()
     ActiveDocument.Tables(1).Range.Select
     With Selection.Find
         .ClearFormatting
         .Forward = True
         .Wrap = wdFindContinue
         .Execute "test"
         
     End With
    End Sub

     And if you don’t select anything in document, it searches the active document.

    >>? What does word use natively for find-replace functionality?<<
    You can refer code below to replace the specific text in the word document:

    Selection.Find.Execute "Test", replacewith:="Test1", Replace:=wdReplaceAll

    In addition, you can get more detail from link below:
    Find Object

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by bansal_r Wednesday, April 23, 2014 7:04 AM
    Wednesday, April 16, 2014 3:33 AM
    Moderator
  • Hi Bansal

    This behavior has been confirmed as a bug and should be fixed in a future update, but I have no information as to when this will be released...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by bansal_r Friday, April 25, 2014 9:47 AM
    Wednesday, April 23, 2014 4:33 PM
    Moderator

All replies

  • Hi Rahul,

    Did you want to search the words in a specific range? If so, as a workaround you can select the specific range, then use the selection to search. Here is a sample for your reference:

    Sub FindInTable()
     ActiveDocument.Tables(1).Range.Select
     With Selection.Find
         .ClearFormatting
         .Forward = True
         .Wrap = wdFindContinue
         .Execute "test"
         
     End With
    End Sub

     And if you don’t select anything in document, it searches the active document.

    >>? What does word use natively for find-replace functionality?<<
    You can refer code below to replace the specific text in the word document:

    Selection.Find.Execute "Test", replacewith:="Test1", Replace:=wdReplaceAll

    In addition, you can get more detail from link below:
    Find Object

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by bansal_r Wednesday, April 23, 2014 7:04 AM
    Wednesday, April 16, 2014 3:33 AM
    Moderator
  • Hi Fei,

    So can i conclude following 2 things from your mail:

    i) Word itself uses Selection.Find.Execute. Correct?

    ii) Range.Find.Execute CRASH is Microsoft Bug. Is there any plan to fix this bug as it seems critical?
    And why is it happening for merged tables scenarios only?

    Also, is Selection.Find the only work around? Actually Selection.Find is not desired in my code as it will result in selection change event as well. My code does hell lot of things in selection change event, so i'll need to bypass all those and then i will need to restore selection to original state as well.

    Regards,
    Rahul

    Thursday, April 17, 2014 5:25 AM
  • Hi Rahul,

    >>i) Word itself uses Selection.Find.Execute. Correct?<<

    Yes.

    >>ii) Range.Find.Execute CRASH is Microsoft Bug. Is there any plan to fix this bug as it seems critical?
    And why is it happening for merged tables scenarios only?<<

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards

    Fei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 21, 2014 1:41 AM
    Moderator
  • I would expect you to receive a more complete set of answers to your question in the Word forum, rather than in the Access Database forum.

    peter n roth - http://PNR1.com, Maybe some useful stuff

    Monday, April 21, 2014 3:23 PM
  • Hi Fei,

    Is there any update on this? 

    Wednesday, April 23, 2014 7:01 AM
  • Hi Bansal

    This behavior has been confirmed as a bug and should be fixed in a future update, but I have no information as to when this will be released...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by bansal_r Friday, April 25, 2014 9:47 AM
    Wednesday, April 23, 2014 4:33 PM
    Moderator
  • Hi Bansal

    This behavior has been confirmed as a bug and should be fixed in a future update, but I have no information as to when this will be released...


    Cindy Meister, VSTO/Word MVP, my blog

    Is this bug fixed now?

    Antony

    Friday, January 9, 2015 11:01 AM