Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2014, 11:19 PM
macropod's Avatar
macropod macropod is offline Extracting certain text before footnote number Windows 7 64bit Extracting certain text before footnote number Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,518
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

That requires a rather different approach. Try the following macro. It converts your document to a table, which it then sorts by reference #. That way, all the references are gouped together. There do seem to be some anomalies/inconsistencies with your data, in that you sometimes have multiple names without references, followed by one or more references in a row, but not always the same number of references as names.



The output table sorts all reference series by the first reference in that series. It seems to produce consistent results.
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument
  With .Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchWildcards = True
      .Text = "\["
      .Replacement.Text = "^t"
      .Execute Replace:=wdReplaceAll
      .Text = "\]*[\;^13]"
      .Replacement.Text = "^p"
      .Execute Replace:=wdReplaceAll
      .Text = "\(*\)"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
      .Text = "^s"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
      .Text = ","
      .Wrap = wdFindStop
      .Execute
    End With
    Do While .Find.Found
      If .Hyperlinks.Count = 0 Then .Text = vbTab
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
  With .Range
    .ConvertToTable
    With .Tables(1)
      .Columns.Width = 36
      .Columns(1).Width = 144
      .Sort ExcludeHeader:=False, CaseSensitive:=False, LanguageID:=wdEnglishUS, _
        FieldNumber:="Column 2", SortFieldType:=wdSortFieldNumeric, SortOrder:=wdSortOrderAscending, _
        FieldNumber2:="Column 1", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:=wdSortOrderAscending
    End With
  End With
End With
Application.ScreenUpdating = True
End Sub
Because your document is full of hyperlinks, doing any kind of processing that has to consider their display text (as would be required if you wanted to extract only those names associated with reference #34, for example) would be much more complicated than working with simple text.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-26-2014, 12:27 AM
Taisir Taisir is offline Extracting certain text before footnote number Windows 7 64bit Extracting certain text before footnote number Office 2010 64bit
Novice
Extracting certain text before footnote number
 
Join Date: Nov 2014
Posts: 4
Taisir is on a distinguished road
Default Extracting certain text before footnote numbe

Dear Paul,
Many thanks again for the prmpt reply.
Your mew VBA solution is great and provided me with many other benefits that I can use.

I really appreciate your help.

All the best

Next I will try to mark this inquiry as SOLVED.
Cjeers
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting certain text before footnote number Heading's Footnote's number is displayed in TOC. How to remove the number in TOC? Orehrepus Word 1 07-13-2014 12:51 PM
Extracting certain text before footnote number VBA code to read number of footnote and enter in text rekent Word VBA 2 05-13-2014 06:53 AM
Extracting certain text before footnote number Extracting a phone number from a string that contains text and numbers. hommi16 Excel 2 06-05-2013 09:19 PM
number in footnote line ScientificKat Word 2 07-09-2012 06:25 AM
Footnote text is not aligned with the corresponding number Patrick1988 Word 0 08-28-2010 09:33 PM

Other Forums: Access Forums

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


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