![]() |
|
#1
|
|||
|
|||
![]() i am working on a 190k word (so far) document with 137 citations. at some point it becomes impossible to update the source list. after laboring for .5hr or so it crashes Word. I've uninstalled and reinstalled both Word 2007 and 2013. I could probably recover an older version of the file before this problem but then would have to figure out to merge the new data into it, maybe doable, maybe not. if i can't fix this i'll have to freeze the existing source structure (convert to static text) then manage sources manually until completion. any suggestions greatly appreciated. |
#2
|
||||
|
||||
![]()
The first thing to do is to make a backup of your bibliography references. Assuming they're all replicated in Word's Sources.xml file, you can make a copy of that or use the following SourcesExport macro to extract them to text in a new document:
Code:
Sub SourcesExport() Dim oSrc As Source, StrSrc As String With ActiveDocument .Range.Text = vbNullString For Each oSrc In Application.Bibliography.Sources StrSrc = StrSrc & vbCr & oSrc.XML Next .Range.InsertAfter StrSrc .Paragraphs.First.Range.Delete End With End Sub Sub SourcesImport() Dim i As Long 'In case the source is already present On Error Resume Next With ActiveDocument For i = 0 To UBound(Split(.Range.Text, vbCr)) Application.Bibliography.Sources.Add Split(.Range.Text, vbCr)(i) Next End With End Sub C:\Users\%Username%\AppData\Roaming\Microsoft\ Putting that string into Windows Explorer's address bar should take you to the folder on your system. A 190KB Word document is quite small, so you're a long way from pressing up against any operating limits. It's possible, though, that the document has acquired some for of corruption. Corrupt documents can often be 'repaired' by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template (headers & footers may need to be copied separately), closing the old document and saving the new one over it. If that doesn't resolve things, try closing Word, then deleting the Sources.xml file (which may be corrupt), before re-starting Word. Word should create a new one and you can then use the SourcesImport macro to restore the bibliography entries to it. Hopefully the problem will now go away. The 137 citations could adversely affect the document's performance, too, because of the way Word handles their building block containers. A way around this is to replace the existing building block citations with citation fields - and do the same to the bibliography. The following macro does just that. Code:
Sub DeleteReferenceBuilingBlocks() Application.ScreenUpdating = False Application.DisplayAlerts = wdAlertsNone Dim i As Long, iRng As Long, StrCode As String Dim Stry As Range, Rng As Range, Fld As Field, Stl As String With ActiveDocument For Each Stry In .StoryRanges Select Case Stry.StoryType Case wdFootnotesStory, wdEndnotesStory, wdMainTextStory 'loop through all fields, starting from the end of the story For i = Stry.Fields.Count To 1 Step -1 With Stry.Fields(i) 'get the field type If .Type = wdFieldCitation Then StrCode = Trim(.Code.Text) Set Rng = .Result.Duplicate iRng = Len(Rng.Text) .Select WordBasic.BibliographyCitationToText Rng.MoveEnd wdCharacter, iRng If Rng.Characters.First.Previous = " " Then Rng.Start = Rng.Start - 1 End If Set Fld = Rng.Fields.Add(Range:=Rng, Type:=wdFieldEmpty, _ Text:="REF " & StrCode, Preserveformatting:=False) Fld.Code.Text = Trim(Replace(Fld.Code.Text, "REF ", "")) ElseIf .Type = wdFieldBibliography Then StrCode = Trim(.Code.Text) Set Rng = .Result.Duplicate With Rng .MoveStart wdParagraph, -2 Stl = .Paragraphs(1).Style .Start = .Start - 1 .End = .End + 2 .Text = vbNullString .Collapse wdCollapseStart .Text = vbCr & "Bibliography" & vbCr .Paragraphs(2).Style = Stl .Collapse wdCollapseEnd End With Set Fld = Rng.Fields.Add(Range:=Rng, Type:=wdFieldEmpty, _ Text:=StrCode, Preserveformatting:=False) End If End With Next Stry.Fields.Update Case Else End Select Next End With Set Rng = Nothing: Set Fld = Nothing Application.DisplayAlerts = wdAlertsAll Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
sorry, i should've said a 190KB-word "Word" document. the file size is about 3MB.
interesting. i found the sources.xml file at C:\Users\%Username%\AppData\Roaming\Microsoft\Bibl iography decided to make a copy of the working file to play with, then went back to the above location to delete the .xml and...it was gone? no change in behavior when updating references in the working or copy files. i have a dumb (text) copy of the references. being the functional equivalent of a novice user, i'll have to take the time to learn how to run macros to try your solution and get back to you. Thanks much. on another note: where would one look for a MS Word pro who could solve problems like this as a service? |
#4
|
|||
|
|||
![]()
I meant of course 190K
|
#5
|
||||
|
||||
![]()
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
On a side note, it's also possible the document has acquired some for of corruption or that your Office installation is itself faulty. Corrupt documents can often be 'repaired' by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template (headers & footers may need to be copied separately), closing the old document and saving the new one over it. You could also try repairing the Office installation (via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
where can i find this SourceImport macro to which you referred? also, is there an easy way to convert all citation references in a doc to text? thx
|
#7
|
||||
|
||||
![]()
It's in post #2...
Do note that it's only designed for importing references in the xml format Word uses - which is what the SourcesExport macro produces. The following macro converts a document’s Citations & Bibliography to static text. Note the use of WordBasic ! for this. Note also that converting a Bibliography to static text does not remove it’s building block container – a form of content control. A trivially-simple alternative is to save the file in Word's doc format. Code:
Sub References_Unlink() Dim Fld As Field, FtNt As Footnote, EndNt As Endnote With ActiveDocument For Each Fld In .Fields If Fld.Type = wdFieldCitation Then Fld.Select WordBasic.BibliographyCitationToText ElseIf Fld.Type = wdFieldBibliography Then Fld.Select WordBasic.BibliographyCitationToText End If Next For Each FtNt In .Footnotes For Each Fld In FtNt.Range.Fields If Fld.Type = wdFieldCitation Then Fld.Select WordBasic.BibliographyCitationToText End If Next Next For Each EndNt In .Endnotes For Each Fld In EndNt.Range.Fields If Fld.Type = wdFieldCitation Then Fld.Select WordBasic.BibliographyCitationToText End If Next Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
![]()
saving as a .doc is genius! did exactly what i needed without buggering the formatting or anything else. giving up completely on Word referencing for performance reasons. things are moving along relatively apace with those ref's removed.
thanks very much. case closed. |
#9
|
||||
|
||||
![]()
FWIW, I have at least one document with over 100 citations, plus 67 bibliography references, and those have little effect on its performance. I suspect something else is/was going on with your document.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]()
anything's possible after a clean windows installation. for some reason if not the above things are MUCH faster and the incessant repaginating has stopped. depending on how long i live, the source list will grow indefinitely and i no longer trust word's system...i'm glad it's gone. fortunately this isn't a dissertation--source sequencing is hardly a concern. thanks again.
|
#11
|
||||
|
||||
![]()
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 |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
beanie | Word | 5 | 05-24-2014 10:04 AM |
Citations Source Manager Master List empty! | rachetta | Word | 16 | 08-07-2012 03:30 PM |
![]() |
Intruder | Excel | 1 | 08-03-2012 05:41 AM |
Corrupted | strike | Office | 0 | 05-15-2010 03:28 PM |
![]() |
browneyes | Office | 1 | 01-23-2006 02:33 PM |