怎么做網(wǎng)站搜索引擎利于搜索競價惡意點擊報案
Zotero 超鏈接
找了好多原代碼,最接近能實施的為:
https://blog.csdn.net/weixin_47244593/article/details/129072589
但是,就是向他說的一樣會報錯,我修改了代碼,遇見報錯的地方會直接跳過不執(zhí)行,事后找出自己再單獨添加較為特殊文章即可,代碼如下:
Public Sub ZoteroLinkCitation()On Error Resume Next ' Add this line to enable error handlingDim nStart&, nEnd&nStart = Selection.StartnEnd = Selection.EndApplication.ScreenUpdating = FalseDim title As StringDim titleAnchor As StringDim style As StringDim fieldCode As StringDim numOrYear As StringDim pos&, n1&, n2&ActiveWindow.View.ShowFieldCodes = TrueSelection.Find.ClearFormattingWith Selection.Find.Text = "^d ADDIN ZOTERO_BIBL".Replacement.Text = "".Forward = True.Wrap = wdFindContinue.Format = False.MatchCase = False.MatchWholeWord = False.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = FalseEnd WithSelection.Find.ExecuteWith ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="Zotero_Bibliography".DefaultSorting = wdSortByName.ShowHidden = TrueEnd WithActiveWindow.View.ShowFieldCodes = FalseFor Each aField In ActiveDocument.Fields' check if the field is a Zotero in-text referenceIf InStr(aField.Code, "ADDIN ZOTERO_ITEM") > 0 ThenfieldCode = aField.Codepos = 0Do While InStr(fieldCode, """title"":""") > 0n1 = InStr(fieldCode, """title"":""") + Len("""title"":""")n2 = InStr(Mid(fieldCode, n1, Len(fieldCode) - n1), """,""") - 1 + n1title = 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.ClearFormattingWith Selection.Find.Text = Left(title, 255).Replacement.Text = "".Forward = True.Wrap = wdFindAsk.Format = False.MatchCase = False.MatchWholeWord = False.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = FalseEnd WithSelection.Find.ExecuteSelection.Paragraphs(1).Range.SelectWith ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=titleAnchor.DefaultSorting = wdSortByName.ShowHidden = TrueEnd WithaField.SelectSelection.Find.ClearFormattingWith Selection.Find.Text = "^#".Replacement.Text = "".Forward = True.Wrap = wdFindContinue.Format = False.MatchCase = False.MatchWholeWord = False.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = FalseEnd WithSelection.Find.ExecuteSelection.MoveLeft Unit:=wdCharacter, Count:=1Selection.MoveRight Unit:=wdCharacter, Count:=posSelection.Find.ExecuteSelection.MoveLeft Unit:=wdCharacter, Count:=1Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtendnumOrYear = Selection.Range.Text & ""pos = Len(numOrYear)style = Selection.styleActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", SubAddress:=titleAnchor, ScreenTip:="", TextToDisplay:="" & numOrYearaField.SelectSelection.style = style'Selection.style = ActiveDocument.Styles("CitationFormating")fieldCode = Mid(fieldCode, n2 + 1, Len(fieldCode) - n2 - 1)LoopEnd IfNext aFieldActiveDocument.Range(nStart, nEnd).Select
End Sub
超鏈接顏色變化
在這里也給出全盤改變超鏈接顏色的代碼:
參考鏈接如下:https://zhuanlan.zhihu.com/p/680291144
Sub CitingColor()For i = 1 To ActiveDocument.Fields.Count '遍歷文檔所有域' Word 自帶的交叉引用的域代碼起始 4 位是 " REF" (注意空格)' Endnote 插入的引用域代碼的起始 14 位是 " ADDIN EN.CITE"' Zotero 插入的引用域代碼的起始 31 位是 " ADDIN ZOTERO_ITEM CSL_CITATION",可根據(jù)需求添加其他類型If Left(ActiveDocument.Fields(i).Code, 4) = " REF" Or Left(ActiveDocument.Fields(i).Code, 14) = " ADDIN EN.CITE" Or Left(ActiveDocument.Fields(i).Code, 31) = " ADDIN ZOTERO_ITEM CSL_CITATION" ThenActiveDocument.Fields(i).Select ' 選中上述幾類域Selection.Font.Color = wdColorBlue ' 設(shè)置字體顏色為藍色,可改為其他顏色,如 RGB(255,0,0)End IfNext
End Sub
給doi插入超鏈接
參考鏈接
Sub AddHyperlinksToDOIs()Dim doc As DocumentDim rng As RangeDim field As fieldDim doi As StringDim test As StringSet doc = ActiveDocumentSet rng = doc.RangeWith rng.Find.ClearFormatting.Text = "doi:*^13".MatchWildcards = True.Wrap = wdFindStop.Forward = TrueDo While .Executerng.MoveEnd wdCharacter, -1doi = rng.Textdoi = Mid(doi, 6, Len(doi) - 6)rng.Hyperlinks.Add Anchor:=rng, Address:="https://doi.org/" & doi' 移動到下一個匹配項rng.Collapse wdCollapseEndrng.MoveStart wdCharacter, 1LoopEnd With
End Sub