View Single Post
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Yves Dhondt Yves Dhondt is offline
external usenet poster
 
Posts: 767
Default References and Bibliographies

There is no direct way to achieve what you want. If you are lucky enough
that your bibliography is sorted by occurence in the text (numerical
mostly), then the entries that weren't cited in your work will be at the
bottom of the list. Otherwise, you will have to use a workaround.

Using the \f flag on a bibliography field you can display only those entries
that belong to a certain language in your bibliography. So what you can do
is assign a fake language to all your cited works and assign another fake
language to all uncited works. Then you can add 2 different bibliographies
to your work, each one with one of your fake languages.

The following macro automates this process. It will present you with 2
inputboxes. In the first one you will have to enter your language id (1033
is the one for English, for all others see
http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx). In the second, you
will have to enter a number indicating if you want the full bibliography,
only the cited works, or only the uncited works. Once you added a
bibliography of a certain type, you should convert it to static text so that
it can no longer get updated by accident.

Watch for line wraps when copying this macro. For more info on installing
macros, see http://www.gmayor.com/installing_macro.htm

!!! CREATE A BACKUP OF YOUR DOCUMENT BEFORE RUNNING THIS MACRO !!!

==== BEGIN MACRO ====

Sub InsertBibliographyEx()
' Input parameters
Dim bibtype As Integer ' 0 = all, 1 = cited only, 2 = uncited only
Dim locale As String ' LCID code of the entire bibliography

bibtype = 1
locale = "1033"

Do
locale = InputBox("Insert the 4-digit LCID code for your language." & _
vbCrLf & "In case of doubt, enter 0. (1033 = US English)" & vbCrLf & _
"For a full list, see
http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx", _
"LCID value", Application.Language)
Loop While locale 0 Or locale 9999

Do
bibtype = InputBox("Make your choice:" & vbCrLf & " 0 - Display all
sources" & _
vbCrLf & " 1 - Display cited works only" & vbCrLf & " 2 - Display
uncited works only", _
"What do you want to display?", bibtype)
Loop While bibtype 0 Or bibtype 2

' Local constants
Const lcidCited As String = "1117" ' Inuktitut (cited sources)
Const lcidUncited As String = "1098" ' Telugu (uncited sources)

' Local variables.
Dim src As Source
Dim idx As Integer
Dim tags() As String
Dim lcids() As String
Dim size As Integer
Dim code As String

' Init variables.
idx = 1
size = ActiveDocument.Bibliography.Sources.Count
ReDim tags(1 To size)
ReDim lcids(1 To size)

' Generate the code for the field.
If bibtype = 0 Then
code = "BIBLIOGRAPHY \l " + locale
ElseIf bibtype = 1 Then
code = "BIBLIOGRAPHY \l " + locale + " \f " + lcidCited
ElseIf bibtype = 2 Then
code = "BIBLIOGRAPHY \l " + locale + " \f " + lcidUncited
Else
MsgBox "Invalid bibtype specified!", vbExclamation, "Error"
End
End If

' Preprocess all sources in the document.
For Each src In ActiveDocument.Bibliography.Sources
' Make a local copy of the original language setting of a source.
tags(idx) = src.field("Tag")
lcids(idx) = src.field("LCID")
idx = idx + 1

' Set the language of a source according to the fact if it is cited or
not.
If src.Cited = False Then
src.field("LCID") = lcidUncited
Else
src.field("LCID") = lcidCited
End If
Next

' Insert the bibliography field.
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:=code, PreserveFormatting:=False
' Update the bibliography field.
Selection.Fields.Update

' Restore the language settings of all the sources.
' (inefficient, a dictionary would be better here)
' (not sure if the collection does not change order, so direct mapping is
a no go)
For Each src In ActiveDocument.Bibliography.Sources
' Locate the position of the tag in the array we stored.
idx = 1
While (src.field("Tag") tags(idx))
idx = idx + 1
Wend

' Use that index to restore the language code
src.field("LCID") = lcids(idx)
Next

End Sub

==== END MACRO ====



"ChrisP" wrote in message
...
I've been using the new citation tools in Word 2007 and was wondering if
it
was possible to create separate bibliographies and citation lists.

I would ideally like 2 lists, one with all documents cited (references),
the
other will all documents in the sources list not cited (bibliography).

I can create the cited list, but a full bibliography includes these
aswell,
meaning they appear twice.

Any help welcomed!