Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2020, 12:50 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 Extract words which has superscripts and the corresponding superscript value in footnotes in word

Hi Everyone,

I am new to vba. I need to extract the words which have superscripts from the main document part and the corresponding superscript value in footnotes.

For example :

Main Doc has : Doctor^1

Footnotes has : 1. Sample Citation

I need to extract something like this into excel



Doctor, 1, Sample Citation

Any help is much appreciated. Thanks
Reply With Quote
  #2  
Old 05-10-2020, 03:48 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: 21,617
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

Extracting a single word preceding a footnote seems fairly meaningless, as footnotes typically relate to rather more than just the last preceding word. A simple way of copying all footnotes without code is to open any footnote, then press Ctrl-A, Copy. You can then paste them into Excel and use the text-to-columns function to split the footnote references from the content.

PS: Kindly post Word VBA questions in the Word VBA forum. You post does not concern 'Forum Support'. I have moved the thread to the correct forum.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-10-2020, 08:40 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 Extract words which has superscripts

Hi

I think you did not get my point.

Example :

Lets say I have a sentence like : he is good^1 ( 1 is the superscript and if I double click on 1 it will navigate to the first footnotes) in the word document

So I would like to extract the word "good"(which has superscript) and the superscript value(i.e. 1) .


Thank you.
Reply With Quote
  #4  
Old 05-10-2020, 08:44 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: 21,617
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

Quote:
Originally Posted by sai View Post
I think you did not get my point.
Quite the contrary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-10-2020, 08:48 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
Default

No word vba for this task?
Reply With Quote
  #6  
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: 21,617
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
  #7  
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
  #8  
Old 05-10-2020, 09:43 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: 21,617
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

What you're getting is what you specified in post 1:
Quote:
Originally Posted by sai View Post
I need to extract the words which have superscripts from the main document part and the corresponding superscript value in footnotes.

For example :

Main Doc has : Doctor^1

Footnotes has : 1. Sample Citation
and which is what I queried in post 2:
Quote:
Originally Posted by macropod View Post
Extracting a single word preceding a footnote seems fairly meaningless, as footnotes typically relate to rather more than just the last preceding word.
only for you to come back with
Quote:
Originally Posted by sai View Post
I think you did not get my point.
I think now you get my point...

So how is the macro to know when you want one word only, or multiple words?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 05-10-2020, 11:01 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

Is there a chance to extract multiple words?
Reply With Quote
  #10  
Old 05-10-2020, 11:03 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: 21,617
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

Yes, but you have to say what the rules are in a way a macro can identify how many words to get. Macros don't know what case names are, for example.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 05-10-2020, 11:12 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
Default

The rule would be : need to extract case name which are in italic with the text " v " included.
Reply With Quote
  #12  
Old 05-10-2020, 11:24 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: 21,617
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 the revised code in post 6.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 05-11-2020, 04:29 AM
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
Default

Thank a ton.

This looks good.
Reply With Quote
Reply

Tags
extract superscript word

Thread Tools
Display Modes


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 10:24 PM.


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