locked
Wait for DTE.Find.FindReplace() to complete? RRS feed

  • Question

  •  I am using a macro in Visual Studio 2010 to find a regular expression in the project files with the results going to "Find Results 1". I am using FindReplace similar to the excerpt below:

          DTE.Find.FindReplace(vsFindAction.vsFindActionFindAll, _
                                   pre & what & post, _
                                   vsFindOptions.vsFindOptionsRegularExpression + vsFindOptions2.vsFindOptionsWaitForFindToComplete, _
                                   "", _
                                   vsFindTarget.vsFindTargetCurrentProject, _
                                   sSearchPath, _
                                   sFilesOfType, _
                                   nResults)

    I follow this with a macro that reads the contents of the "Find Results 1" pane. However, I am reading the results before the find completes. How can I ensure the FindReplace completes before I read the "Find Results 1" pane?

    Regards,

    Frank

    Wednesday, February 8, 2012 4:03 PM

Answers

  • I did not try the OR operator because I do not think that would make a difference, and I do not know that vsFindOptionsWaitForFindToComplete is even a valid option for this call.

    I have solved the problem by using events, and do not need further assistance.

    Regards,

    Frank

    • Marked as answer by Yi Feng Li Monday, February 20, 2012 1:59 AM
    Friday, February 17, 2012 2:28 PM

All replies

  • Hi Frank,

    That vsFindOptionsWaitForFindToComplete should do the trick. I'm not much of a VB programmer, but I'd guess you need to combine those vsFindOptions with a bitwise And.

    Sincerely,


    Ed Dore

    Wednesday, February 8, 2012 5:44 PM
  • Actually I think the vsFindOptionsWaitForFindToComplete option applies to ReplacePattern(). I do not know if it applies to FindReplace() - I was just trying my luck, and it did not seem to help. (And the plus operator for the options is fine.)

    Regards,

    Frank

    Wednesday, February 8, 2012 7:57 PM
  • Hi Frank,

    Did you try Or operator for these options?

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, February 9, 2012 9:18 AM
  • Hi,



    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Regards,

    Yi



    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, February 17, 2012 3:32 AM
  • I did not try the OR operator because I do not think that would make a difference, and I do not know that vsFindOptionsWaitForFindToComplete is even a valid option for this call.

    I have solved the problem by using events, and do not need further assistance.

    Regards,

    Frank

    • Marked as answer by Yi Feng Li Monday, February 20, 2012 1:59 AM
    Friday, February 17, 2012 2:28 PM
  • Thanks for your update

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, February 20, 2012 1:57 AM