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?
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.
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 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
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.
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.)
Maybe we could also use VB to hyperlink the references to the bibliography?
Did I mention it works perfectly? It does ;)
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).
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
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