插入时报错“item”不是一种属性

异常报告 · 445 次浏览
zaoshuizaoqi1 创建于 2023-10-28 00:22


ttChen 2023-11-08 21:20 :

收到,最近很忙,闲下来处理。最好能提供调试报告。

回复内容
RushQQ 2023-12-18 11:28
#1

修复了该问题的报错,但是不能二次分享,很可惜

RushQQ 回复 RushQQ 2023-12-18 17:54 :

将此段代码替换AHKV2的内容,保存后运行即可

$$IsStyleExists(doc,name)
{
    Loop doc.Styles.Count
    {
        style := doc.Styles.Item(A_Index)
        if (style.NameLocal = name) {
            return true
        }
    }
    return false
}

ChangFieldColor(doc)
{
    Loop doc.Fields.Count
    {
        field := doc.Fields.Item(A_Index)
        r := field.Result
        if (InStr(field.Code.Text, " ADDIN ZOTERO_ITEM") = 1) {

            if (InStr(r.Text,"(")=1 or InStr(r.Text,"[")=1 or InStr(r.Text,"(")=1)
            {
                r.SetRange(r.Start + 1, r.End - 1)
                

            } else {
                pos:= RegExMatch(r.Text, "\(\d{4}\w?\)", &OutputVar)
                if(pos>0)
                {
                    r.SetRange(r.Start + pos, r.Start + pos + StrLen(OutputVar[])-2)
                }
            }
            r.Style:="zoteroCitation"
        }

    }
    return
}

citation := 'ADDIN ZOTERO_ITEM CSL_CITATION {Citations}'
Word := ComObjActive("Word.Application")
winactive("A")
doc := Word.ActiveDocument
Word.ScreenUpdating := False
doc.Fields.Add(Word.Selection.Range, 17, citation, true)
Word.Run("Zotero.ZoteroRefresh")
Sleep 1000
if(!IsStyleExists(doc,"zoteroCitation")){
     doc.Styles.Add("zoteroCitation", 2)
     doc.Styles["zoteroCitation"].Font.ColorIndex := 2
}
ChangFieldColor(doc)
Word.ScreenUpdating := true

ttChen 2024-01-26 09:27
#2
AHK2版本更新导致的错误,已更新!
江晓先生s 2024-02-29 19:58
#3

具体如何解决

回复主贴