Exempt Zotero fields from being spell-checked (Word 2010)

Since normally in-document Zotero fields only contain names, it makes sense to want to exclude them from being spell-checked, when this operation is performed in a document. Is there a way to instruct Zotero (or WOrd) to do this?
  • not for Zotero, no.
  • I see. For a long document full of APA-style references, it is a bit of a pain to be clicking Ignore All over and over again. Do you think it's worth posting this suggestions in the Feedback/Wishlist section of the forum?
  • not really, no. I don't see Zotero trying to communicate with the spell-checker of the word processing software - if that's even possible, which I doubt. But what's so bad about having a couple of red underlinings in your document? Who still goes through those one by one?
  • I'm not sure if this is even possible, but it does sound like it would be useful.

    I think you can change the category of your post by editing the initial post-- feel free to move this to the Feature Requests area.

    Disabling spellcheck for specific pieces of text is done via the language options: http://www.techrepublic.com/blog/msoffice/how-to-skip-text-during-spell-check/3168
    I don't know if this is something that Zotero can do through Word's scripting system, but maybe it is.
  • edited February 21, 2011
    "Who still goes through those one by one?" - I still do :-) Otherwise I'm tempted to go back and correct every red-underlined typo, which distracts me unnecessarily. I find it's much cleaner to do it once in one go, before submitting/printing the document. I realise it's a personal preference, but if others have this preference as well (and I know many people do) then I would add this to the wish list, and let the developers decide if it's worth (or, indeed, possible) to implement.

    ajlyon, it seems you can use that option to only exclude contiguous blocks of text, I doubt this is a practical option for in-text references.
  • I don't mean for you to exclude the text manually in that way, but if it possible for Zotero to prevent spell-checking automatically using that method, then we're set. We'd still have to be careful about prefixes and suffixes, which might contain user text, but I think we could do it. Fortunately, however, I know nothing about the macros we use to work with Word.
  • edited May 29, 2011
    This is not complex to implement.
    I wrote these two MS Word (2003) macros to perform the task, they could potentially be merged to the Zotero Word plugin. The first one set all the Zotero in-text reference text in the document to be ignored by the proofing tools. The second reverts the action.

    (I prepared a small toolbar in a Word template with buttons for this, but I am not sure of how to provide files to the fourm).
    (And sorry, but the code indentation is lost when publishing the post).
    Congratulations to the Z team!

    Regards,
    Martin

    Public Sub DeactivateProofingOfZoteroFields()
    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
    aField.Select
    Selection.NoProofing = True
    End If
    Next aField
    End Sub

    Public Sub ActivateProofingOfZoteroFields()
    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
    aField.Select
    Selection.NoProofing = False
    End If
    Next aField
    End Sub
  • Hi Martin, many thanks for this code. The problem of having to skip through hundreds of Zotero fields (citations) when spell-checking a word document is still driving me mad. I was wondering if you happened to have developed your code to also work with newer versions of Word (2010)? Disappointingly, the WinWord integration in the new Zotero 3.0 doesn't have the option to skip citation fields either..
  • edited June 19, 2012
    Longtalker, Martin's macro works fine in Word 2010. To use it:
    1. turn on the developer tab
    2. Open Visual Basic and create a new module in Normal template
    3. paste in Martin's code. Close visual basic.
    4. Create a new shortcut to the macro ("customize quick access toolbar"). Choose commands from from macros, and find "DeactivateProofingOfZoteroFields". choose an icon you'll remember.
    If you click the button, the macro zips through your document, and spellcheck ignores anything in your citations. Awesome! Ideally it would ignore the bibliography too, but that's easy to skip in spellcheck.
  • edited February 23, 2013
    (I didn't find it right away, so here's how to: )

    For activating the developer tab go to "options" > highlight "Popular" group on the left then check the box that says "Show Developer Tab in the Ribbon" on the right.

    And the "customize quick access toolbar" can be accessed by clicking on the dropdown icon in the quick access toolbar on the top next to the Office logo. (Yes, i am quite blind sometimes.)
  • edited February 23, 2013
    Could this be used to Set a certain Style for the Zotero items too (one would need to exclude the bibliography)? That's a feature I was missing, because the references always revert to default style, which is annoying. And btw, switching between spellchecking on and off could be done using the style (maybe this can be manipulated through VB too?).

    Maybe we could also use VB to hyperlink the references to the bibliography?

    Did I mention it works perfectly? It does ;)
  • edited March 3, 2013
    I have simplified the code to the following:
    Public Sub SetZoteroCitationFormating()
    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
    aField.Select
    Selection.Style = ActiveDocument.Styles("CitationFormating")
    End If
    Next aField
    End Sub
    Now you just have to set a style named "CitationFormating" before running the script. There you can set the NoProofing and other Formating (like kursive). Removing is also easy, just delete the style.

    If someone knows visual basic more, then the style settings could be done once if the style is not yet defined. Additionally, Fields that are already styled should be skipped for quicker usage and the script should start at the cursor (so you can place it just before the element you just added). The cursor should also return to the position it was before (so you can continue writing).
  • So here's the update:

    Now the cursor returns to where it was before!

    Public Sub SetZoteroCitationFormating()
    Dim nStart&, nEnd&
    nStart = Selection.Start
    nEnd = Selection.End
    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
    aField.Select
    Selection.Style = ActiveDocument.Styles("CitationFormating")
    End If
    Next aField
    ActiveDocument.Range(nStart, nEnd).Select
    End Sub
  • It would be awesome if Zotero marked all author names as "Ignore all", so that they do not appear as underlined even outside of Zotero fields. This is the kind of detail that makes software look so smart.
  • edited September 15, 2013
    I have rewritten Martin's code to make it runnable in LibreOffice Writer. Hope it helps!


    Sub DeactivateProofingOfZoteroFields
    Dim oReferenceMarks
    Dim oReferenceMark
    Dim oReferenceNames
    Dim anchor


    REM noLocale tip as seen in "OpenOffice.org Macro Information"
    REM by Andrew Pitonyak

    Dim noLocale As New com.sun.star.lang.Locale
    noLocale.Country = ""
    noLocale.Language = "zxx"


    oReferenceMarks = ThisComponent.getReferenceMarks()
    oReferenceNames = oReferenceMarks.getElementNames()
    For i = LBound(oReferenceNames) to UBound(oReferenceNames)

    sName = oReferenceNames(i)

    if (InStr(sName, "ZOTERO") = 1) then
    oReferenceMark = oReferenceMarks.getByName(sName)
    anchor = oReferenceMark.getAnchor()
    anchor.CharLocale = noLocale
    end if

    Next i

    End Sub

Sign In or Register to comment.