Μετάβαση στο κύριο περιεχόμενο

Πώς να βρείτε και να επισημάνετε διπλές παραγράφους στο έγγραφο του Word;

Ας υποθέσουμε, έχετε ένα μεγάλο έγγραφο του Word που μπορεί να έχει εκατοντάδες σελίδες, τώρα, θέλετε να ελέγξετε αν υπάρχουν διπλές παραγράφους και στη συνέχεια να επισημάνετε για να τις κάνετε εξαιρετικές, ώστε να μπορείτε να αντιμετωπίσετε τις διπλές προτάσεις. Πώς θα μπορούσατε να βρείτε και να επισημάνετε τις διπλές παραγράφους γρήγορα και εύκολα στο έγγραφο του Word;

Βρείτε και επισημάνετε τις διπλές παραγράφους στο έγγραφο του Word με τον κώδικα VBA


Βρείτε και επισημάνετε τις διπλές παραγράφους στο έγγραφο του Word με τον κώδικα VBA

Για να βρείτε και να επισημάνετε τις διπλές παραγράφους σε ένα έγγραφο του Word, ο ακόλουθος κώδικας VBA μπορεί να σας βοηθήσει, κάντε το εξής:

1. Κρατήστε πατημένο το ALT + F11 για να ανοίξετε το Microsoft Visual Basic για εφαρμογές παράθυρο.

2. Και μετά, κάντε κλικ στο Κύριο θέμα > Μονάδα μέτρησης, αντιγράψτε και επικολλήστε τον παρακάτω κώδικα στην κενή κενή ενότητα:

Κωδικός VBA: Βρείτε και επισημάνετε τις διπλές παραγράφους στο έγγραφο του Word:

Sub highlightdup()
    Dim I, J As Long
    Dim xRngFind, xRng As Range
    Dim xStrFind, xStr As String
    Options.DefaultHighlightColorIndex = wdYellow
    Application.ScreenUpdating = False
    With ActiveDocument
        For I = 1 To .Paragraphs.Count - 1
            Set xRngFind = .Paragraphs(I).Range
            If xRngFind.HighlightColorIndex <> wdYellow Then
                For J = I + 1 To .Paragraphs.Count
                    Set xRng = .Paragraphs(J).Range
                    If xRngFind.Text = xRng.Text Then
                        xRngFind.HighlightColorIndex = wdBrightGreen
                        xRng.HighlightColorIndex = wdYellow
                    End If
                Next
            End If
        Next
    End With
End Sub

3. Και στη συνέχεια πατήστε F5 κλειδί για την εκτέλεση αυτού του κώδικα, όλες οι διπλές προτάσεις επισημαίνονται ταυτόχρονα, οι πρώτες διπλότυπες παράγραφοι που εμφανίζονται επισημαίνονται με πράσινο χρώμα και άλλες διπλές επισημαίνονται με κίτρινο χρώμα, δείτε το στιγμιότυπο οθόνης:

doc highlight διπλές προτάσεις 1

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

Kutools για το Word - Βελτιώστε την εμπειρία σας στο Word με το Over 100 Αξιοσημείωτα χαρακτηριστικά!

🤖 Kutools AI Assistant: Μεταμορφώστε το γραπτό σας με AI - Δημιουργία Περιεχομένου  /  Ξαναγράψτε το κείμενο  /  Συνοψίστε τα έγγραφα  /  Ζητήστε πληροφορίες με βάση το Έγγραφο, όλα μέσα στο Word

📘 Κυριαρχία εγγράφων: Διαίρεση σελίδων  /  Συγχώνευση εγγράφων  /  Εξαγωγή επιλογής σε διάφορες μορφές (PDF/TXT/DOC/HTML...)  /  Μαζική μετατροπή σε PDF  /  Εξαγωγή σελίδων ως εικόνες  /  Εκτύπωση πολλών αρχείων ταυτόχρονα...

Επεξεργασία Περιεχομένων: Μαζική εύρεση και αντικατάσταση σε πολλά αρχεία  /  Αλλαγή μεγέθους όλων των εικόνων  /  Μεταφορά σειρών και στηλών πίνακα  /  Μετατροπή πίνακα σε κείμενο...

🧹 Καθαρισμός χωρίς κόπο: Σαρώστε μακριά Επιπλέον χώροι  /  Διακοπές ενότητας  /  Όλες οι κεφαλίδες  /  Κουτιά κειμένου  /  Υπερ-συνδέσεις  / Για περισσότερα εργαλεία αφαίρεσης, κατευθυνθείτε στο δικό μας Κατάργηση ομάδας...

Δημιουργικά ένθετα: Εισάγετε Χιλιάδες Διαχωριστές  /  Πλαίσια ελέγχου  /  Κουμπιά ραδιοφώνου  /  QR Code  /  barcode  /  Διαγώνιος γραμμικός πίνακας  /  Λεζάντα εξίσωσης  /  Λεζάντα εικόνας  /  Λεζάντα πίνακα  /  Πολλαπλές εικόνες  / Ανακαλύψτε περισσότερα στο Εισαγωγή ομάδας...

🔍 Επιλογές Ακρίβειας: Επισήμανση συγκεκριμένες σελίδες  /  πίνακες  /  σχήματα  /  επικεφαλίδες παραγράφους  / Βελτιώστε την πλοήγηση με περισσότερο Επιλέξτε χαρακτηριστικά...

Βελτιώσεις αστεριών: Πλοηγηθείτε γρήγορα σε οποιαδήποτε τοποθεσία  /  αυτόματη εισαγωγή επαναλαμβανόμενου κειμένου  /  εναλλαγή μεταξύ των παραθύρων εγγράφων  /  11 Εργαλεία μετατροπής...

???? Θέλετε να δοκιμάσετε αυτές τις δυνατότητες; Το Kutools για το Word προσφέρει α Δωρεάν δοκιμαστική περίοδο 60, χωρίς περιορισμούς! 🚀
 
Comments (15)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Can you help me it is not working can you helphttps://1drv.ms/w/s!Aja8bo-tfhqb-FVWcGUyvYPv07cX?e=lgJ4i1
This comment was minimized by the moderator on the site
Hi, mình chạy đoạn code trên nhưng không thấy ra kết quả giống bài viết, mình dùng word 2019, Ad support giúp mình nhé 
This comment was minimized by the moderator on the site
Hi, can anyone please suggest me to prepare a macro in ms word for finding error in paragraph.
Like:- "and or" "that that" "of the of the" "Sentence end without dot (.)" "New Sentence start with initial caps without ending the sending".
This comment was minimized by the moderator on the site
Thanks so much.A very valuable article, helped me with my duplicate copies and paste paragraphs!You are awesome.
This comment was minimized by the moderator on the site
Tried this for my book in MS Word. First, it would not work because I had bullet points. I removed them and then it only found 2 instances "blank page" and "table of contents". I purposely have several sentences repeated, and this macro did not find them. Thank you for trying, but I would say this doesn't work.
This comment was minimized by the moderator on the site
I had a very long document to process, the code above would take at least 100 days to finish and blocked everything while working at it. The main culprit is the "Set xRng = .Paragraphs(J).Range" which is very slow. I did an alternative version which ran in just 4 hours and presents a continuous report on the processing status and time to end. (To see the report in real time you have to open the "immediate window" by pressing Ctrl+G in the Microsoft Visual Basic for Applications window.) The code works well, except that it predicts a longer time to end than is actually the case (depends on the document). The code is as follows:

Sub highlightdup()
Dim StartTime, SecondsElapsed As Date
Dim secondsPerComparison As Double
Dim I, J, PC, totalComparisons, comparisonsDone, C, secondsToFinish As Long
Dim xRngFind, xRng As Range
Dim xStrg, minutesToFinish As String
Dim currentParag, nextParag As Paragraph
'Options.DefaultHighlightColorIndex = wdYellow
Application.ScreenUpdating = False
With ActiveDocument
StartTime = Now()
C = 0
PC = .Paragraphs.Count
totalComparisons = CLng((PC * (PC + 1)) / 2)
Set currentParag = .Paragraphs(1)
For I = 1 To PC - 1
'Debug.Print "processing paragraph " & I & " of a total of " & PC & " " & currentParag.Range.Text
'Debug.Print Len(currentParag) & currentParag
If currentParag.Range.HighlightColorIndex <> wdYellow Then
If currentParag.Range.HighlightColorIndex <> wdBrightGreen Then
Set nextParag = currentParag
For J = I + 1 To PC
Set nextParag = nextParag.Next
If currentParag.Range.Text = nextParag.Range.Text Then
currentParag.Range.HighlightColorIndex = wdBrightGreen
nextParag.Range.HighlightColorIndex = wdYellow
Debug.Print "found one!! " & " I = " & I & " J = " & J & nextParag.Range.Text
End If
Next
End If
End If
DoEvents
comparisonsDone = PC * (I - 1) + (J - I)
SecondsElapsed = DateDiff("s", StartTime, Now())
secondsPerComparison = CLng(SecondsElapsed) / comparisonsDone
secondsToFinish = CLng(secondsPerComparison * (totalComparisons - comparisonsDone))
minutesToFinish = Format(secondsToFinish / 86400, "hh:mm:ss")
elapsedTime = Format(SecondsElapsed / 86400, "hh:mm:ss")
Debug.Print "Finished procesing paragraph " & I & " of " & PC & ". Elapsed time = " & elapsedTime & ". Time to finish = " & minutesToFinish
Set currentParag = currentParag.Next
Next
End With
End Sub
This comment was minimized by the moderator on the site
Hi there! Thank you so much for this code. When I first tried to use it there was a syntax error that kept popping up. But, upon looking at the above code and this code I found a way to make it work and I figured it might help someone else: (Just follow the instructions above but copy and paste this instead) if you're finding yours is having a Syntax error like mine.

PC = .Paragraphs.Count
totalComparisons = CLng((PC * (PC + 1)) / 2)
Set currentParag = .Paragraphs(1)
For I = 1 To PC - 1
'Debug.Print "processing paragraph " & I & " of a total of " & PC & " " & currentParag.Range.Text
'Debug.Print Len(currentParag) & currentParag
If currentParag.Range.HighlightColorIndex <> wdYellow Then
If currentParag.Range.HighlightColorIndex <> wdBrightGreen Then
Set nextParag = currentParag
For J = I + 1 To PC
Set nextParag = nextParag.Next
If currentParag.Range.Text = nextParag.Range.Text Then
currentParag.Range.HighlightColorIndex = wdBrightGreen
nextParag.Range.HighlightColorIndex = wdYellow
Debug.Print "found one!! " & amp; " I = " & amp; I & amp; " J = " & amp; J & amp; nextParag.Range.Text
End If
Next
End If
End If
DoEvents
comparisonsDone = PC * (I - 1) + (J - I)
SecondsElapsed = DateDiff("s", StartTime, Now())
secondsPerComparison = CLng(SecondsElapsed) / comparisonsDone
secondsToFinish = CLng(secondsPerComparison * (totalComparisons - comparisonsDone))
minutesToFinish = Format(secondsToFinish / 86400, "hh:mm:ss")
elapsedTime = Format(SecondsElapsed / 86400, "hh:mm:ss")
Debug.Print "Finished procesing paragraph " & amp; I & amp; " of " & amp; PC & amp; ". Elapsed time = " & amp; elapsedTime & amp; ". Time to finish = " & amp; minutesToFinish
Set currentParag = currentParag.Next
Next
End With
End Sub
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Thank you, you saved my day already twice. This work like magic.
This comment was minimized by the moderator on the site
thank you very much, it works perfectly and very quickly !

Paul (from France)
This comment was minimized by the moderator on the site
Sir, kindly thank you and please have good winds in your life.
This comment was minimized by the moderator on the site
Hello



Thank you for the helping



But how can I find the same sentences in my text?



Regards
This comment was minimized by the moderator on the site
Hello

Thank you for the helping

But how can I find the same sentences in my text?

Regards
This comment was minimized by the moderator on the site
It throws Compile error: Syntax error, the code is 100% as the example.
This comment was minimized by the moderator on the site
I tried, and it works fine!
I just wanted to know - could I do the same thing - but not a whole paragraph, but a sentence with a few words I'd set up - like 10 words?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations