参考文献格式:
引用格式:
查看宏
宏
Public Sub ZoteroLinkCitation()
Dim nStart&, nEnd&
nStart = Selection.Start
nEnd = Selection.End
Application.ScreenUpdating = False
Dim title As String
Dim titleAnchor As String
Dim style As String
Dim fieldCode As String
Dim numOrYear As String
Dim pos&, n1&, n2&
ActiveWindow.View.ShowFieldCodes = True
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^d ADDIN ZOTERO_BIBL"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Zotero_Bibliography"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
ActiveWindow.View.ShowFieldCodes = False
For Each aField In ActiveDocument.Fields
' check if the field is a Zotero in-text reference
If InStr(aField.Code, "ADDIN ZOTERO_ITEM") > 0 Then
fieldCode = aField.Code
pos = 0
Do While InStr(fieldCode, """title"":""") > 0
n1 = InStr(fieldCode, """title"":""") + Len("""title"":""")
n2 = InStr(Mid(fieldCode, n1, Len(fieldCode) - n1), """,""") - 1 + n1
title = Mid(fieldCode, n1, n2 - n1)
titleAnchor = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(title, " ", "_"), "&", "_"), ":", "_"), ",", "_"), "-", "_"), ".", "_"), "(", "_"), ")", "_"), "?", "_"), "!", "_")
titleAnchor = Left(titleAnchor, 40)
Selection.GoTo What:=wdGoToBookmark, Name:="Zotero_Bibliography"
Selection.Find.ClearFormatting
With Selection.Find
.Text = Left(title, 255)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Paragraphs(1).Range.Select
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=titleAnchor
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
aField.Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=pos
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
numOrYear = Selection.Range.Text & ""
pos = Len(numOrYear)
style = Selection.style
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", SubAddress:=titleAnchor, ScreenTip:="", TextToDisplay:="" & numOrYear
aField.Select
Selection.style = style
'Selection.style = ActiveDocument.Styles("CitationFormating")
fieldCode = Mid(fieldCode, n2 + 1, Len(fieldCode) - n2 - 1)
Loop
End If
Next aField
ActiveDocument.Range(nStart, nEnd).Select
End Sub
注:要为生成的链接设置样式
,请取消注释该行, 并在那里写下您的样式。
'Selection.style = ActiveDocument.Styles("CitationFormating")
代码链接: Zotero
宏
宏
ZoteroLinkCitation前提:已经插入好引用,并构建好参考文献了。这个宏只是将两者添加超链接。
技巧:可以插完全部参考文献再运行!!
注意:该方法根据标题
将作者日期或数字样式引用链接到他们的参考文献条目。它在字段中搜索数字
(年份或序号),选择它,然后将其链接到 zotero 字段中的标题。尚不支持上标样式,因为选择数字会导致整个字段被链接替换。
1. 问题界面:
2. 点击 调试,会出现下面的界面,会提示出现有问题的文献:
解决办法:
检查标题,会议名称,页码等信息。
注:这个错误是标题
出现问题了。
找其他正确的文献,把正确的标题复制
过来,在这个正确的基础上修改成自己的标题名称。
在重新添加文献,最后在运行宏
。
打开Zotero软件,按照“编辑——首选项——引用——样式”,添加参考文献的格式;
打开word软件,光标放在插入参考文献的位置,按照“Zotero——document preferences”,选中期刊参考文献的格式,点击“Add/Edit citation”添加或编辑参考文献,会出来一个搜索框,在框内输入题目或是姓名查找文献,点击文献即可。如果多个参考文献,就继续输入题目,添加文献。再次回车,可以看到word文档中已经出现该引文;
插入该文献列表:在需要的位置点击Add/Edit Bibliography插入该文献列表,插入后检查参考文献格式是否正确,如果不正确点击Add/Edit Bibliography编辑参考文献,点击右侧参考文献,进行修改,都修改后,点击OK;
运行宏,生成连接。