Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2020, 09:06 PM
macropod's Avatar
macropod macropod is offline Extract words which has superscripts and the corresponding superscript value in footnotes in word Windows 7 64bit Extract words which has superscripts and the corresponding superscript value in footnotes in word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 ExportFootnotes()
Dim Rng As Range, StrOut As String, StrTmp As String, i As Long, j As Long, xlApp As Object, xlWkBk As Object
StrOut = "Reference,Footnote #,Footnote Text"
StrOut = Replace(StrOut, ",", vbTab)
With ActiveDocument
  ' Process the Footnotes
  For i = 1 To .Footnotes.Count
    With .Footnotes(i)
      Set Rng = .Reference.Words.First.Previous.Words.First
      With Rng
        Do While .Words.First.Previous.Font.Italic = True
          .Start = .Words.First.Previous.Words.First.Start
        Loop
        If InStr(.Text, " v ") = 0 Then .Start = .Words.Last.Start
      End With
      StrOut = StrOut & vbCr & Rng.Text & vbTab & _
        i & vbTab & Replace(Replace(.Range.Text, vbTab, "<TAB>"), vbCr, "<P>")
    End With
  Next
End With
' Test whether Excel is already running.
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
'Start Excel if it isn't running
If xlApp Is Nothing Then
  Set xlApp = CreateObject("Excel.Application")
  If xlApp Is Nothing Then
    MsgBox "Can't start Excel.", vbExclamation
    Exit Sub
  End If
End If
On Error GoTo 0
With xlApp
  Set xlWkBk = .Workbooks.Add
  ' Update the workbook.
  With xlWkBk.Worksheets(1)
    For i = 0 To UBound(Split(StrOut, vbCr))
      StrTmp = Split(StrOut, vbCr)(i)
        For j = 0 To UBound(Split(StrTmp, vbTab))
          .Cells(i + 1, j + 1).Value = Split(StrTmp, vbTab)(j)
        Next
    Next
    .Columns("A:C").AutoFit
  End With
  ' Tell the user we're done.
  MsgBox "Done.", vbOKOnly
  ' Switch to the Excel workbook
  .Visible = True
End With
' Release object memory
Set xlWkBk = Nothing: Set xlApp = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 05-10-2020, 09:36 PM
sai sai is offline Extract words which has superscripts and the corresponding superscript value in footnotes in word Windows 10 Extract words which has superscripts and the corresponding superscript value in footnotes in word Office 2010
Novice
Extract words which has superscripts and the corresponding superscript value in footnotes in word
 
Join Date: May 2020
Posts: 8
sai is on a distinguished road
Post

Thank you for the quick response. Below code is extracting the last word which has superscript.

StrOut = StrOut & vbCr & .Reference.Words.First.Previous.Words.First & vbTab & _
i & vbTab & Replace(Replace(.Range.Text, vbTab, "<TAB>"), vbCr, "<P>")

Is there a way I could extract the entire case name like I have attached in the screenshot.

output like : Kruger v Coetzee (Full Case Name)
Reply With Quote
Reply

Tags
extract superscript word



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract words which has superscripts and the corresponding superscript value in footnotes in word How to change superscript footnotes into genuine Word footnotes Knounte29 Word VBA 41 01-16-2020 04:48 PM
Extract words which has superscripts and the corresponding superscript value in footnotes in word Help with Footnotes! Superscript and Numbering Issues Mitavec Word 13 10-21-2018 01:37 PM
Extract words which has superscripts and the corresponding superscript value in footnotes in word turn footnotes and their respective superscripts into normal text GEORGEJUNGCOCAINE Word VBA 2 02-27-2018 10:01 PM
turn footnotes and their respective superscripts into normal unlinkable text GEORGEJUNGCOCAINE Word 1 02-27-2018 05:47 PM
Footnotes/Citations not superscript wordquery Word 3 04-12-2017 01:55 PM

Other Forums: Access Forums

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