Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2014, 05:07 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Removing Duplicate Text in a Document

Hi all,



I have the following information in a document. I would like to find a solution/macro to remove the duplicates.

Question #1 (ACCCC.101111REG)

Question #1 (ACCCC.101111REG)

Question #2 (ACCCC.101112.TXT)

Question #2 (ACCCC.101112.TXT)

Question #3 (ACCCC.101113REG)

Question #3 (ACCCC.101113REG)


Thanks!
Reply With Quote
  #2  
Old 10-24-2014, 07:04 PM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Another wildcard Find/Replace job:
Find = (Question #[0-9]@ \(ACCCC*\)^13)\1
Replace = \1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-25-2014, 12:01 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Hi Macropod,

Not sure if I am the problem (surely I am) but I can't get it to work. Can you check the below code?

Thanks,


PHP Code:
Sub macroDeletingDoubleMCQ()
'
lMacroDeletingDoubleMCQ
'
'
    
Selection.Find.ClearFormatting
    Selection
.Find.Replacement.ClearFormatting
    With Selection
.Find
        
.Text "Question #[0-9]@ \(ACCCC*\)^13)\1"
        
.Replacement.Text "\1"
        
.Forward True
        
.Wrap wdFindContinue
        
.Format False
        
.MatchCase False
        
.MatchWholeWord False
        
.MatchAllWordForms False
        
.MatchSoundsLike False
        
.MatchWildcards True
    End With
    Selection
.Find.Execute Replace:=wdReplaceAll
End Sub 
Reply With Quote
  #4  
Old 10-25-2014, 12:13 AM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your .Text = expression isn't what I posted.

What separates the entries? The Find/Replace expression I posted assumes a single paragraph break.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-25-2014, 05:47 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Hi Macropod,

First, I tried the Find/Replace option as you suggested, but did not work for me.


Second, tried to put it in a macro but still does not work for me.

Sorry, but I don't know how to get this to work.




PHP Code:
Sub MacroDeletingDoubleMCQ() 

lMacroDeletingDoubleMCQ 


    
Selection.Find.ClearFormatting 
    Selection
.Find.Replacement.ClearFormatting 
    With Selection
.Find 
        
.Text "(Question #[0-9]@ \(ACCCC*\)^13)\1" 
        
.Replacement.Text "\1" 
        
.Forward True 
        
.Wrap wdFindContinue 
        
.Format False 
        
.MatchCase False 
        
.MatchWholeWord False 
        
.MatchAllWordForms False 
        
.MatchSoundsLike False 
        
.MatchWildcards True 
    End With 
    Selection
.Find.Execute Replace:=wdReplaceAll 
End Sub 
Reply With Quote
  #6  
Old 10-25-2014, 06:46 AM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Please answer the question I asked in my last post.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 10-25-2014, 07:46 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Sorry, but I can't answer you question you asked me before, simply because I have no idea, I really don't know.

I thought the problem was the missing parentheses in my code so I went back to the macro I recorded with WORD, add the parenthesis but still don't know where the problem is. There might be some other code within the macro that is wrong, but I don't where..

I feel guilty and stupid by not being able to know or answer this or execute the wildcard Find/Replace job.

Of course, and if you don't mine and have the time, would you be able to put this with a simple macro/code with a single paragraph break and another macro or instructions on how to do it with a double paragraph break so I can test it and see what I did wrong?



Thank you!

Cheers,
Reply With Quote
  #8  
Old 10-25-2014, 02:25 PM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It's not a matter of me putting anything in a macro, but of what your document contains. Click on the ¶ symbol on the ribbon's Home tab. What to you see between the closing parenthesis in:
Question #1 (ACCCC.101111REG)
and the 'Q' in:
Question #1 (ACCCC.101111REG)

The Find/Replace assumes you'll see:
Question #1 (ACCCC.101111REG)¶

Question #1 (ACCCC.101111REG)

not:
Question #1 (ACCCC.101111REG)¶

Question #1 (ACCCC.101111REG)

or:
Question #1 (ACCCC.101111REG) ¶

Question #1 (ACCCC.101111REG)

Alternatively, can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 10-26-2014, 05:06 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

I went back to the sample file I was using and noticed the symbol was not the right one. Now, it has the right ¶ symbol.

After doing the corrections, the wildcard function is working.

Yes, today I learned something new and as you stated "It's not a matter of me putting anything in a macro, but of what your document contains".

Good point...

Thank you so much!


Regards,
rsrasc
Reply With Quote
  #10  
Old 10-26-2014, 05:14 AM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If your document showed ↵ instead of ¶ at the end of each line, all that would have been required is to change the Find expression's ^13 to ^11.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 10-26-2014, 06:20 AM
rsrasc rsrasc is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 64bit
Competent Performer
Removing Duplicate Text in a Document
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Thanks, I did the deadly mistake of copying and pasting the information that I posted in the thread and used it to test the wildcard, and yes indeed, it has the ↵ symbol instead of ¶, that why it didn't work from the beginning.

Question, could you please tell me if it is possible to combine both expression in the same argument?

Thanks again!
Reply With Quote
  #12  
Old 10-26-2014, 02:02 PM
macropod's Avatar
macropod macropod is offline Removing Duplicate Text in a Document Windows 7 64bit Removing Duplicate Text in a Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use:
Find = (Question #[0-9]@ \(ACCCC*\))[^11^13]\1
Replace = \1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Locating and removing large, duplicate blocks of copy in word markaffleck Word 2 06-05-2014 10:12 PM
Removing blank pages at the end of a document Xanzia Word 3 06-01-2014 11:13 AM
Removing Duplicate Text in a Document Finding duplicate sentences in a document seascape Word VBA 1 02-18-2014 12:31 AM
Removing duplicate index entries Bengt Word 5 03-01-2013 02:01 AM
Saving Word document creates a duplicate transparent file bbailey Word 0 12-05-2009 10:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:57 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