Thread: [Solved] corrupted source list?
View Single Post
 
Old 10-17-2015, 09:53 PM
Guessed's Avatar
Guessed Guessed is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The Bibliography in a docx/docm is stored as a CustomXMLPart and this can be extracted to an xml file if you wanted to save all those items in a structured file format which can be edited with text editors or xml tools and then placed back into the document. The following code would extract that file to the same folder as the document.
Code:
Sub WriteBibliographyToFile()
  Dim xmlPart As CustomXMLPart
  Dim sFilename As String
  
'  For Each xmlPart In ActiveDocument.CustomXMLParts
'    Debug.Print xmlPart.ID & vbTab & xmlPart.NamespaceURI
'  Next xmlPart
  
  Set xmlPart = ActiveDocument.CustomXMLParts.SelectByNamespace("http://schemas.openxmlformats.org/officeDocument/2006/bibliography").Item(1)
  If Not xmlPart Is Nothing Then
    sFilename = ActiveDocument.Path & "\Bibliography.xml"
    'Debug.Print xmlPart.XML
    Call WriteStringToFile(sFilename, xmlPart.XML)
  End If

End Sub
Sub WriteStringToFile(pFileName As String, pString As String)
  Dim intFileNum As Integer
  intFileNum = FreeFile
  Open pFileName For Output As intFileNum
    Print #intFileNum, pString
  Close intFileNum
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote