Trigger Word macro on creating/modifying cite field
Whenever Zotero adds or modifies a cite field in word, I'd like to trigger a Word macro to do something with that field. Is this possible?
--
Specifically, I'm trying to create a workaround for this problem:
https://forums.zotero.org/discussion/comment/314401/#Comment_314401
I want author-only cites (inverse of "suppress author"), but I'm not getting a reply or suggestions in the other thread.
(I think this can be done by supplying a page number of "0" and then recognizing that within word, and modifying the cite field accordingly. Not pretty, but I hope it works.)
--
Specifically, I'm trying to create a workaround for this problem:
https://forums.zotero.org/discussion/comment/314401/#Comment_314401
I want author-only cites (inverse of "suppress author"), but I'm not getting a reply or suggestions in the other thread.
(I think this can be done by supplying a page number of "0" and then recognizing that within word, and modifying the cite field accordingly. Not pretty, but I hope it works.)
Thanks!
But when I do that, I end up calling the Zotero function, then the Zotero menu opens, and in the background my personal macro runs, so it doesn't wait until the Zotero process is done.
Trying to figure out the timing here, but any advice would be appreciated :)
Here's the macro I'm trying to run after Zotero finishes updating a field:
Application.Run MacroName:="ZoteroInsertCitation"
fieldLoc = ActiveDocument.Range(0, Selection.End).Fields.Count ' find the ID of the last field up to the current cursor/selection
If fieldLoc > 0 Then ' if there is a last field
fieldText = ActiveDocument.Fields(fieldLoc).Code.Text ' get the current text of the field
If InStr(fieldText, " ADDIN ZOTERO_ITEM CSL_CITATION") = 1 Then ' make sure this is a Zotero field to modify
ZoteroFieldFix ActiveDocument.Fields(fieldLoc) ' change field to author-only
End If
End If
End Sub
"ZoteroFieldFix" is a separate function that actually modifies the field. That seems to work without any issues, but obviously must take place after Zotero has finished changing the field or it is pointless.
[*I found some suggestions about alternatives to the Shell command that would be synchronous, waiting for the result, but I would rather not have to change Zotero.dot. On the other hand, it is kind of odd that you can continue editing/working on Word while Zotero is open and is going to presumably change things after you have edited something else in the document. But that's outside the scope of this discussion I suppose.]
https://forums.zotero.org/discussion/73159/announcing-zoterzero-for-author-only-cites