Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-27-2014, 10:17 AM
foneunlocker foneunlocker is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Mar 2014
Posts: 5
foneunlocker is on a distinguished road
Default How to remove text from Word Document

Hi

I wonder if someone can help me with the sort of thing i want to do with MS Word.


For example i have a large document with this format

IMEI 0141050003641xxx
NCK (Network Control Key) code 1431118294


NSCK (Network Subset Control Key) code 0789752304
SPCK (Service Provider Control Key) code 1848274449
IMEI 0141050001xxx
NCK (Network Control Key) code 4100906854
NSCK (Network Subset Control Key) code 2275808812
SPCK (Service Provider Control Key) code 3213140214

0141050003xxxx
NCK (Network Control Key) code 3412249181
NSCK (Network Subset Control Key) code 3890809715
SPCK (Service Provider Control Key) code 4110099951

IMEI 0141050003xxxx
NCK (Network Control Key) code 0962742612
NSCK (Network Subset Control Key) code 3008125359
SPCK (Service Provider Control Key) code 0683725000

Now, from each imei i want to remove middle codes NSCK (Network Subset Control Key) code 0789752304 and just leave out NCK and SPCK.

i tried ctrl+f but this won't help because each line has different numbers...and this removes matching bit only which is NSCK (Network Subset Control Key) code

I hope you know what i am trying to achieve when i have to do this with large number of imeis.

many Thanks
Reply With Quote
  #2  
Old 11-27-2014, 08:36 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,648
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Try a wildcard Find/Replace, where:
Find = (IMEI [0-9]*[^13^l])*[^13^l]*[^13^l]*[^13^l]{1,}
Replace = \1
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 11-27-2014, 11:43 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 2,223
gmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the rough
Default

With due deference to Paul, who is a whizz with find and replacement strings, I don't think this one does what you intend. Nor is it entirely clear what you want to remove and what you want to keep.

From your description I assumed you wanted to keep the IMEI line and the NCK line and remove the other two lines
OR
Keep the IMEI line and the NSCK and SPCK lines and remove the NCK line,

so in the following macro I have provided code options to do either - http://www.gmayor.com/installing_macro.htm

Code:
Sub RemoveParas()
Dim oPara As Paragraph
Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=Chr(11))
            oRng.Text = Chr(13)
            oRng.Collapse wdCollapseEnd
        Loop
    End With
    For Each oPara In ActiveDocument.Paragraphs
        oPara.Range.ParagraphFormat.SpaceAfter = 0
        
        'Option 1 ________________________
        'If Trim(oPara.Range.Words(1).Text) = "NCK" Or _
         Trim(oPara.Range.Words(1).Text) = "SPCK" Then oPara.Range.Delete
         '-------------------
         
         'Option 2
        If Trim(oPara.Range.Words(1).Text) = "NSCK" Then oPara.Range.Delete
        '--------------------
    Next oPara
End Sub
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 11-28-2014, 12:51 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,648
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by gmayor View Post
Nor is it entirely clear what you want to remove and what you want to keep.
Agreed. The F/R expression I posted assumes only the IMEI lines are to be kept. Modifying it to keep other lines as well is not a big deal.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way remove periods at the end of every bullet in a document? ravl13 Word 3 06-12-2014 04:55 PM
hard lines across document - can't remove joanieS Word 3 07-30-2013 11:29 AM
Remove all images from a Mac OS X Word 2008 Document? qcom Word 0 04-23-2011 06:48 PM
Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Remove text in start up document Sheila Word 1 09-30-2010 03:33 PM


All times are GMT -7. The time now is 03:37 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft