Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 06-15-2012, 05:38 PM
donlincolnmsof donlincolnmsof is offline Extract phone number from word file Windows 7 64bit Extract phone number from word file Office 2003
Advanced Beginner
Extract phone number from word file
 
Join Date: Oct 2011
Posts: 36
donlincolnmsof is on a distinguished road
Smile Extract Phone number from word file

Hello Paul

Thanks for the macro, it worked great.!!

After running the macro I realized that there was more data that need to be extracted. And they are in a block format.


The format of the block is below


beginning code=abc bunch of data 908+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data



Sample Data
===========

beginning code=abc bunch of data 908+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 908+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data beginning code=abc bunch of data 510+555-1212 ending code=xyz garbage data garbage data garbage data garbage data garbage data


I was able to locate the 9 digit phone number with the following code.
Code:
Do
  Selection.Find.ClearFormatting
  With Selection.Find
    .Text = "^?^?^?+^?^?^?-^?^?^?^?"
    .Replacement.Text = """"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  Selection.Find.Execute
  Selection.MoveRight Unit:=wdCharacter, Count:=2
  Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
  Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
  Selection.Cut
  Windows(2).Activate
  Selection.Paste
  Selection.TypeParagraph
  Windows(1).Activate
Loop Until Selection.Find.Found = False
what the macro should do is to start from the beginning of the file,

1) find the 9 digits number and take out that whole record into a new window

2) now the next few records are just in sequence following the 1st record, so the macro should check to see if the next records have the same number, if it finds it then it should delete THAT NUMBER and then check for the next record and so on, once
it finds a unique number then it should extract THAT RECORD AND ADD IT DOWN BELOW 1ST RECORD THAT WAS EXTRACTED IN THAT NEW WINDOW.

any help would be greatly appreciated.

Thanks a lot.

Last edited by macropod; 06-15-2012 at 06:22 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract phone number from word file Extract Video from .ppsx file designer PowerPoint 1 10-14-2011 08:00 AM
Extract phone number from word file Phone number formatting Mark Micallef Outlook 1 08-04-2010 02:38 PM
Can I Extract a Page from Word and Make a New DOCX File? tatihulot Word 1 06-20-2010 11:38 PM
in WORD, how do i type a 9-digit phone number "xxxxxxxxx" and have it automatically.. jay8962 Word 0 04-08-2010 11:08 AM
automatically extract footnotes into new file and apply character format to footnote hrdwa Word 0 02-27-2010 03:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:23 AM.


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