Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 06-25-2023, 05:28 PM
Guessed's Avatar
Guessed Guessed is offline check for duplicates of a word within next 100 words Windows 10 check for duplicates of a word within next 100 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,994
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Harvi007



For large documents this macro is not efficient enough to perform the vast amount of processing required - 9 hours is certainly too long. It is possible to add an update the Status Bar to show progress but if it is running that slowly, then you have bigger fish to fry.

Working page to page is a concept that doesn't really get you anywhere though and it has the added complexity of having to include the following page content in the search boundary as soon as you are within the distance limit of the end of the page.

This question is largely an academic exercise as far as I'm concerned so I don't want to waste a large block of time to figure out a more efficient way of performing it. Can you explain the value of adding a bunch of highlights to text that indicate proximity of the same word? What value does it add to a document and how does it improve your work?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #17  
Old 06-25-2023, 05:50 PM
Harvi007 Harvi007 is offline check for duplicates of a word within next 100 words Windows 11 check for duplicates of a word within next 100 words Office 2019
Novice
 
Join Date: Aug 2022
Posts: 11
Harvi007 is on a distinguished road
Default

Hi, Thank you for getting back to me.

So basically, I'm doing some work on a set of scriptures I've typed up.

For typing purposes the words are separated by a space, but when looking to publish, the words will be joined up into one line.

Now to read in this form, it takes a great deal of learning etc. I've come up with an idea where by I use alternate colours with the words, so when joined up, you can still make out the word due to it being a different colour.

Here is were I have an issue... the colour coding script doesn't like consecutive repeat words i.e. the the or is is as an example.

It flips the colour pattern, so where it would be: red, black, red, black, red, black
when it comes to these repeat words, it will go: red, black, black, red, red, black

with that said, if we when join up the words, 2 black words will join implying that it 1 word and 2 red words will join again implying 1 word, which would then be incorrect.

In smaller projects, I've gone through manually and made sure this has not been the case and where it has been, I've manually changed it.

With this larger project, I wanted something that would highlight these consecutive repeat words so that it would be easier for me to find and correct.

I'm happy to provide the colour coding code to see if that can be fixed to take into account consecutive repeating words perhaps?

Short of this, it would just mean going through manually

I hope this background helps.

Any help on this would be much appreciated.

Thank you,
Reply With Quote
  #18  
Old 06-25-2023, 11:01 PM
Guessed's Avatar
Guessed Guessed is offline check for duplicates of a word within next 100 words Windows 10 check for duplicates of a word within next 100 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,994
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

For me personally I can't see any value in tracking how close similar words fall so I'm not going to make time to work on this but I will add some code here that could be used to dramatically speed up the execution.

Hopefully someone will put their hand up and work on a way to make this more efficient and sort out your colouring issue. Macropod himself is less active here nowdays but he may feel like embracing a new challenge if he pops in to have a look around.

The following code collects all the words in the document and records how many times that word appears. You could use this to configure code that ONLY searches for words that occur more than once. This would be way faster.
Code:
Sub GetUniqueWordCounts()
  Dim aDict As New Scripting.Dictionary
  Dim wrd As Variant, sTemp As String, aKey As Variant
  
  With aDict
    For Each wrd In ActiveDocument.Range.Words
      sTemp = Trim(LCase(wrd))
      If Len(sTemp) > 0 Then
        Select Case Asc(sTemp)
          Case 97 To 122        'if the word starts with a lowercase letter it is something we are interested in
            If aDict.Exists(sTemp) Then
              aDict.Item(sTemp) = aDict.Item(sTemp) + 1
            Else
              aDict.Add sTemp, 1
            End If
        End Select
      End If
    Next wrd
  End With

  For Each aKey In aDict.Keys      'audit the values
    Debug.Print aKey, aDict(aKey)
  Next aKey
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #19  
Old 06-26-2023, 08:43 PM
Harvi007 Harvi007 is offline check for duplicates of a word within next 100 words Windows 11 check for duplicates of a word within next 100 words Office 2019
Novice
 
Join Date: Aug 2022
Posts: 11
Harvi007 is on a distinguished road
Default

Thanks for getting back to me.

I had a think and in essence all I'm really wanting to do is find words that are the same colour next to each other.

How would I mod the original code to search on the colour instead?

I'm assuming this might even be a quicker search process perhaps?

Thank you once again for your input on this.
Reply With Quote
  #20  
Old 06-27-2023, 04:10 PM
Guessed's Avatar
Guessed Guessed is offline check for duplicates of a word within next 100 words Windows 10 check for duplicates of a word within next 100 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,994
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The point of the code was to add the colour so modifying it to find colour is "putting the cart before the horse" - ie the colour isn't there to find yet.

Your description of what you actually wanted to do sounds like it is completely unrelated to the code that has been discussed to date
Quote:
For typing purposes the words are separated by a space, but when looking to publish, the words will be joined up into one line.

Now to read in this form, it takes a great deal of learning etc. I've come up with an idea where by I use alternate colours with the words, so when joined up, you can still make out the word due to it being a different colour.

Here is were I have an issue... the colour coding script doesn't like consecutive repeat words i.e. the the or is is as an example.

It flips the colour pattern, so where it would be: red, black, red, black, red, black
when it comes to these repeat words, it will go: red, black, black, red, red, black

with that said, if we when join up the words, 2 black words will join implying that it 1 word and 2 red words will join again implying 1 word, which would then be incorrect.
This sounds like you want to convert content like this
The rain in spain falls mainly on the plain
into
Theraininspainfallsmainlyontheplain
Is that what you are trying to achieve?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
check for duplicates of a word within next 100 words Macro to check against Columns & Delete Duplicates cjamps Excel Programming 27 12-18-2017 06:38 AM
check for duplicates of a word within next 100 words how to check for duplicated words / cells ? iSlam Khaled Word Tables 11 05-05-2015 08:07 PM
check for duplicates of a word within next 100 words Adding words to spell check dictionary oakwoodbank Word 17 02-27-2015 08:09 PM
check for duplicates of a word within next 100 words Spell check adding words riweir Word 3 11-30-2011 09:03 PM
Edit spell check dic to exclude words? franklekens Word 1 07-03-2010 09:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft