1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Replicating EditFind with VBA Dialog Box

Discussion in 'Business Applications' started by KLJKLJ, Jan 22, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. KLJKLJ

    KLJKLJ Thread Starter

    Joined:
    Jan 22, 2013
    Messages:
    4
    I'm trying to do something that should be extremely simple with VBA in Microsoft Word 2010. I'm just trying to replicate the EditFind command (Alt-E, Alt-F on keyboard) to come up with a dialog box. With the following I am able to do almost exactly what I'm trying to do.

    WithDialogs(wdDialogEditFind)
    .WholeWord = True
    .Display
    End With

    The frustrating thing I am encountering is that although this displays the dialog box, after the user enters the search term he cannot just use the Enter key to carry out the search (nothing happens if he does). Instead he has to use the "FindNext" button (or keystroke Alt-F), which is cumbersome. Also, the dialog box displays "Word found no items matching this criteria" which makes me think Word tried to do so. All I want is to display the EditFind dialog (with "whole words only" specified) and have the user make the search pressing "Enter."

    Thanks for any attempts in solving this!
     
  2. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,576
    First Name:
    Hans
    Hi, welcome to the forum,
    Could you explain what you need to have the macro do?
    If I understood you questiin correctly to want a user to get a dialog box, enter any text to search for and then keep on searching unitl he / she finds the text nedded? Then what?
    You could record a macro that does that and make sure you press find All.
    Make sure the macro is not saved in the normal.dot but in the current document, then you will have to edit the macro to add the buttons like next or previous, stop, etc.
    With a little more information I van take a look at the vba part, my expertise is Excel but VBA is VBA.
    Let me knwo, if you have document with a macro attach it and I'll see if I can do something for you, no promises, just looking.
     
  3. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,576
    First Name:
    Hans
    Found two macro's edited one and named it FindDialogLoop

    See that attached file
     

    Attached Files:

  4. KLJKLJ

    KLJKLJ Thread Starter

    Joined:
    Jan 22, 2013
    Messages:
    4
    Oh my, I was almost completed writing a reply and something happened that I lost it all. Wonderful computers!

    So, first of all thank you for replying to my post. Unfortunately, it doesn't meet what I'm trying to accomplish head-on. I don't know how to simplify my original request rather than saying I have created a macro that when it is completed issues something like a Dialogs(wdDialogEditFind).Display command to pull up an EditFind dialog, which the user then types in his search string and presses "Enter" to find the first match. Two things are wrong: 1) Once the Find and Replace dialog box comes up and the user types in his search text, he can't just press "Enter", but rather has to click on the "Find Next" button. 2) The dialog box displays the message "Word found no items matching these criteria," whereas Word shouldn't be doing anything in the way of searching before the user does.

    I know this is fairly repetitive of the first post, but I can't really make it more understandable than that. Hope you or someone else can help.

    Thank you.
     
  5. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,576
    First Name:
    Hans
    My point was just to show how the find works in vba, it's just a question of adding a userform where the enter, find next and even find previous could be included.
    But like I asked, what do you want to do when the first find is succesfull, stop/ edit? what?

    Since I don't know that (as I mentioned) I cannot help, more infro would be helpful and if you attach the word file it will be easier to see what you mean.
     
  6. KLJKLJ

    KLJKLJ Thread Starter

    Joined:
    Jan 22, 2013
    Messages:
    4
    Once again, thanks, but I don't want to go into userforms and all that. In a nutshell: I want a macro to do EXACTLY what would happen if you pressed Alt-E, F on the keyboard - nothing more, nothing less. That could be done with a sendkeys command - SendKeys "%EF" - but I obviously don't want to go that route.

    Forgive me for not wanting to go into any more detail than this. I may try to post this on a Microsoft site if my request can't be handled here.

    By the way, all the best in the transition in monarchy in the Netherlands.
     
  7. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,576
    First Name:
    Hans
    Okay, and ... thanks.

    :)
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1086466

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice