Home Getting Source object from footnote (word vba)
 I create footnotes which contains Source objects (a Source object is a single object from Sources list, from which I create Bibliography) All I want to do is to loop through all footnotes and get XML file from each Source object to retrieve information about Author and so on. I have problem with getting Source object from footnotes. I tried to select footnote and retrieve this object from selection but nothing works. Maybe You guys have a proper way to retrieve "parent object" from another object in vba? Sub convertAllFootnotes() Dim ftn As Footnote Dim oRng As Range For Each ftn In ActiveDocument.Footnotes Set oRng = Selection.Range oRng.Start = oRng.Start - 1 oRng.End = oRng.End + 1 oRng.Select oRng.Text = stringFromSource(ftn) 'i don't know how to get source object 'from footnote Next ftn End Sub  string from source function (which works properly, i must pass to it Surce object) Function stringFromSource(curField As Source) As String Set xmlDoc = CreateObject("MSXML2.DOMDocument") xmlDoc.LoadXML curField.XML authors = "": title = "": publish = "": city = "": year = "": periodic = "" 'authors Set surname = xmlDoc.getElementsByTagName("b:Last") Set name = xmlDoc.getElementsByTagName("b:First") Dim l As Integer l = 0 For Each el In surname If el.Text = "" Then Exit For authors = authors + (el.Text & " " & name(l).Text & " ") l = l + 1 Next el 'title Set titlex = xmlDoc.getElementsByTagName("b:Title") For Each el In titlex If el.Text = "" Then Exit For title = title + (el.Text & " ") Next el 'publisher Set pubx = xmlDoc.getElementsByTagName("b:Publisher") For Each el In pubx publish = publish + (el.Text & " ") Next el 'city Set cityx = xmlDoc.getElementsByTagName("b:City") If cityx.Length = 0 Then city = city + ("(brak miasta)" & " ") For Each el In cityx city = city + (el.Text & " ") Next el 'year Set yearx = xmlDoc.getElementsByTagName("b:Year") If yearx.Length = 0 Then year = year + ("(brak roku wydania)" & " ") For Each el In yearx year = year + (el.Text & " ") Next el 'periodical title Set periodx = xmlDoc.getElementsByTagName("b:PeriodicalTitle") For Each el In period periodic = periodic + (el.Text & " ") Next el Dim outputString As String outputString = author & "- " & title & ", " & publish & periodic & ", " & year stringFromSource = outputString End Function