?
Solved

macro help needed - how to auto answer dialogs

Posted on 2011-03-02
1
Medium Priority
?
371 Views
Last Modified: 2012-08-13
I have a macro in MS Word (2007) that loops through all the content making some formatting changes, and then replaces two line breaks with one line break. This last part has to be accomplished 3 times so that all extraneous, empty lines are removed from the page. The macro works, but that last part the user is forced to answer the modal dialog: "Word has finished searching the selection. # replacements were made. Do you want to search the remainder of the document?" with Y/N buttons. I need this question programmatically answered in a fashion that allows the macro to continue through, and then at the very end, I want a modal dialog that says 'Formatting Complete' with an 'OK' button.

Any ideas how to help finish this off?


The code here shows where the dialog is being forced.

(i didn't include the first section as it it's not at issue here..)
..
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^l^l"
        .Replacement.Text = "^l"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Open in new window



Thank you!

Keith
0
Comment
Question by:UPI-ITM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 35019376
Try using the document range instead of the Selection.

Sub RangeFinder()
    With ActiveDocument.Range.Find
            .Text = "^l^l"
            .Replacement.Text = "^l"
            .Execute Replace:=wdReplaceAll
             .Execute Replace:=wdReplaceAll
            .Execute Replace:=wdReplaceAll
   End With
End Sub
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question