link from in-text citation to bibliography (Word)

Is there a way to add a link or a cross-ref from in-text citation to bibliography item with zotero? If yes, please let me know. This is a requirement I need to have in my docs and doing it manually would be really laborious. Thanks.
  • I wrote this some time ago and published it here. I include it again because one of the routines was left off. This is the VBA version for word so will not work in the web based version.

    There are 2 entry points (Sub ZoteroLinkNumberedCitations(), Sub ZoteroLinkAuthorDateCitations()).
    It is not perfect as some types of citation do not work. Use it first on a copy of your document!



    Function multipleReplace(sBmtext, sList)
    Dim iCounter As Integer
    For iCounter = 1 To Len(sList)
    sBmtext = Replace(sBmtext, Mid(sList, iCounter, 1), "")
    Next
    multipleReplace = sBmtext
    End Function

    Function firstWord(oStr)
    firstWord = Split(oStr, " ")(0)
    End Function

    Function getYear(oStr, oExtra)
    Dim searchString As String
    searchString = "\b[0-9]{4,}[a-z]?" & oExtra
    Set re = New RegExp
    re.Global = True
    re.IgnoreCase = False
    re.Pattern = searchString
    getYear = re.Execute(oStr)(0)
    End Function

    Sub insertZoteroLiteratureBookmarks(bmNumbered)
    Dim oRange As Range
    Dim oPara As Paragraph
    Dim oRangePara As Range
    Dim bmtext As String
    For i = 1 To ActiveDocument.Fields.Count
    If InStr(ActiveDocument.Fields(i).Code, "ADDIN ZOTERO_BIBL") Then
    Set oRange = ActiveDocument.Fields(i).Result
    Exit For
    End If
    Next
    For Each oBookMark In oRange.Bookmarks
    oBookMark.Delete
    Next
    iCount = 0
    For Each oPara In oRange.Paragraphs
    Set oRangePara = oPara.Range
    Set bmRange = oRangePara
    iCount = iCount + 1
    If bmNumbered Then
    bmtext = "Ref_" + CStr(iCount)
    Else
    oYear = getYear(oRangePara.Text, "[;:.,\)]")
    bmtext = "Ref_" + oRangePara.Words(1) + "_" + oYear
    bmtext = multipleReplace(bmtext, ":;.,) " & Chr(39) & ChrW(8217) & Chr(13))
    End If
    bmRange.MoveEnd unit:=wdCharacter, Count:=-1
    ActiveDocument.Bookmarks.Add Name:=bmtext, Range:=bmRange
    bmRange.Collapse wdCollapseEnd
    Next
    End Sub
    Sub insertCitationToZoteroLiteratue(bmNumbered)
    Dim i As Long
    Dim oRng As Range
    startingFieldCount = ActiveDocument.Fields.Count
    For i = startingFieldCount To 1 Step -1
    If InStr(ActiveDocument.Fields(i).Code, "ADDIN ZOTERO_ITEM") Then
    Set oRange = ActiveDocument.Fields(i).Result
    With oRange.Find
    .MatchWildcards = True
    If bmNumbered Then
    oRange.Collapse wdCollapseStart
    Do While .Execute("[0-9]{1,}") And oRange.InRange(ActiveDocument.Fields(i).Result)
    bmtext = "Ref_" & oRange.Text
    Set oRng = oRange
    ActiveDocument.Hyperlinks.Add Anchor:=oRng, Address:="", _
    SubAddress:=bmtext, ScreenTip:="", TextToDisplay:=""
    oRange.Collapse wdCollapseEnd
    Loop
    Else
    Do While .Execute("<*([0-9]{4}[a-z,,.;/)])") And oRange.InRange(ActiveDocument.Fields(i).Result)
    bmtext = "Ref_" & firstWord(oRange.Text) & "_" & getYear(oRange.Text, "")
    oRange.MoveEnd unit:=wdCharacter, Count:=-1
    ActiveDocument.Hyperlinks.Add Anchor:=oRange, Address:="", _
    SubAddress:=bmtext, ScreenTip:="", TextToDisplay:=""
    oRange.Collapse wdCollapseEnd
    Loop
    End If
    End With
    End If
    Next i
    End Sub

    Sub ZoteroLinkNumberedCitations()
    insertZoteroLiteratureBookmarks (True)
    insertCitationToZoteroLiteratue (True)
    End Sub

    Sub ZoteroLinkAuthorDateCitations()
    insertZoteroLiteratureBookmarks (False)
    insertCitationToZoteroLiteratue (False)
    End Sub
  • Thanks. Hmmm, do you think there are hopes to get the cross-refs available e.g. in Document Preferences at some point? Working with bookmarks is pretty hard for numerous citations. And for readers, having links in place would be great.
Sign In or Register to comment.