Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-23-2017, 02:59 PM
macropod's Avatar
macropod macropod is offline Convert endnotes into plain text exactly Windows 7 64bit Convert endnotes into plain text exactly Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
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

Try:
Code:
Sub ExportEndNotes()
Application.ScreenUpdating = False
Dim Rng As Range, DocSrc As Document, DocTgt As Document, i As Long, StrRef As String
Set DocSrc = ActiveDocument
With DocSrc
  'Unlink endnote/footnote cross-references
  For i = .Fields.Count To 1 Step -1
    If .Fields(i).Type = wdFieldNoteRef Then .Fields(i).Unlink
  Next
 'Process all endnotes
  For i = 1 To .Endnotes.Count
    'First, process the endnote ref in the document body
    Set Rng = .Endnotes(i).Reference
    With Rng
      .Collapse wdCollapseStart
      'To get the actual reference text, we need to cross-reference it!
      .InsertCrossReference wdRefTypeEndnote, wdEndnoteNumberFormatted, i, False, False
      .End = .End + 1
      StrRef = .Text
      .Fields(1).Unlink
    End With
    'Second, process the endnote ref in the endnote
    Set Rng = .Endnotes(i).Range.Paragraphs.First.Range.Words.First
    With Rng
      If .Characters.Last Like "[ " & vbTab & "]" Then .End = .End - 1
      'Overwrite the existing endnote reference
      .Text = StrRef
    End With
  Next
  'Give Word a chance to do its housekeeping
  DoEvents
  'Create the output document
  Set DocTgt = Documents.Add
  'Replicate the endnotes in the body of the output document
  DocTgt.Range.FormattedText = .StoryRanges(wdEndnotesStory).FormattedText
  'Delete the endnotes from the source document
  For i = .Endnotes.Count To 1 Step -1
    .Endnotes(i).Delete
  Next
End With
Set Rng = Nothing: Set DocTgt = Nothing: Set DocSrc = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert raw field codes to plain text and back again ugcheleuce Word VBA 3 02-14-2017 05:03 AM
Convert endnotes into plain text exactly Macro Needed To Convert Text in Word to Plain Text and Back to Word rsrasc Word VBA 5 12-18-2015 07:13 AM
Convert endnotes into plain text exactly Convert image-text hybrids into plain text morlack Excel 4 12-03-2014 05:29 PM
Convert endnotes into plain text exactly How to convert endnotes in a text doc to Word endnotes? Dickison Word VBA 4 10-06-2012 09:11 PM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM

Other Forums: Access Forums

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