FWIW below is a cut down Sub CallZotero(func) that works for me (with .27 and the Zotero.scpt that you provided). I just got rid of the error handling and calling MacScript.
Sub CallZotero(func) Dim zoteroUrl As String If zoteroUrl = "" Then zoteroUrl = "http://127.0.0.1:23119/integration/macWordCommand?" FileNum = FreeFile() On Error GoTo customUrlNotSet Open Application.StartupPath & Application.PathSeparator & "ZoteroPort.txt" For Input As #FileNum If Not EOF(FileNum) Then Line Input #FileNum, DataLine zoteroUrl = "http://127.0.0.1:" & DataLine & "/integration/macWordCommand?" End If End If
wordAppPath$ = AppleScriptTask("Zotero.scpt", "getPath", "") wordAppPath$ = Replace(wordAppPath$, " ", "%20") #If VBA6 Then Dim majorVersion As Integer majorVersion = Split(Application.Version, ".")(0) If majorVersion >= 16 Then wordVersion$ = "MacWord16" End If #End If
You probably have users where you need to use MacScript? But generally what can be done with AppleScriptTask should be done with AppleScriptTask instead..?
We need to use both MacScript and AppleScriptTask because some people get run-time error 5 with one, and some, with other. We only added the use of AppleScriptTask a couple of years back and before that we used to get quite a few run-time error 5 reports that we have managed to reduce. Initially we tried using only AppleScriptTask, but apparently that causes run-time error 5 for more users than MacScript.
(on first try I encountered a problem, seemed to have been a fluke but just FYI: after clicking/running Insert Citation the AppleScriptTask call led to word becoming unresponsive (needed to force quit), and, when the ScriptEditor was also open, it also froze this app. Can't reproduce and seems to be a macOS issue, or some larger issue, anyway.)
@dgehry: You should make sure you actually have the 6.0.28 version of the plugin in Word. Go to your Word Startup folder, delete Zotero.dotm, restart Word to confirm that Zotero is gone completely, and then close Word and reinstall the plugin from the Cite pane of the Zotero app settings. If the plugin doesn't reappear in Word, see the manual installation instructions.
Hi, going to give this thread a bump because I've been experiencing the same problems with Zotero's add-on for Word. When I click anything on the Zotero toolbar in Word, I get the message "Run-time error '5': Invalid procedure call or argument" with the "continue" and "debug" buttons greyed out. Word doesn't crash or freeze-- it just shows that message then, after I press "end," carries on like I never clicked anything. I have tried uninstalling and reinstalling the Zotero app as well as updating the "Zotero.dotm" file manually to no avail.
I checked and I have Zotero 6.0.28 installed. The Zotero standalone app lists the version of the Zotero add-on as 6.0.10.SA.6.0.30. I am using Microsoft Word 16.78.3 (23102801) with an Office Home & Student 2021 license. I am currently running macOS Sonoma 14.1.1 (23B81) on a personal MacBook Pro 2019 with built-in Retina display and an Intel chip. I am not running any security software besides what comes standard with the MacBook Pro, and my MacBook has not indicated the activation of any security features recently. I have very little familiarity with how Visual Basic works, so I'm afraid I cannot be of much help on that front.
@cmfiddes: You should have Zotero 6.0.30 installed, not 6.0.28, but presumably you do if you have 6.0.10.SA.6.0.30 of the plugin?
Make sure you're running 6.0.30, go to your Word Startup folder, delete Zotero.dotm, restart Word, and confirm that Zotero is completely gone from Word. Then follow the steps under Zotero Toolbar Doesn't Appear to reinstall the plugin.
@cmfiddes if you're unable to investigate in Word by checking which line our plugin code fails on, it's going to be hard to offer you any more specific advice. Generally this is caused by Word being unable to message Zotero, which in the past meant that either Word was unable to use AppleScript for some reason, or security software was getting in the middle between Word and Zotero. If it's the former, then creating a new macOS user account and seeing if it works there might help reset whatever configuration is preventing AppleScript from being used by Word.
Hello. Same error here. I think it is due to osascript not being able to run for security reasons after a security update on my macos Monterey.
I have the latest word and the latest zotero. I've tried deleting the dotm, replacing it with the versions above, deleting again and reinstalling. Still error 5 when I try to insert a citation...
Sub CallZotero(func)
that works for me (with .27 and the Zotero.scpt that you provided). I just got rid of the error handling and callingMacScript
.Sub CallZotero(func)
Dim zoteroUrl As String
If zoteroUrl = "" Then
zoteroUrl = "http://127.0.0.1:23119/integration/macWordCommand?"
FileNum = FreeFile()
On Error GoTo customUrlNotSet
Open Application.StartupPath & Application.PathSeparator & "ZoteroPort.txt" For Input As #FileNum
If Not EOF(FileNum) Then
Line Input #FileNum, DataLine
zoteroUrl = "http://127.0.0.1:" & DataLine & "/integration/macWordCommand?"
End If
End If
customUrlNotSet:
nl$ = Chr$(10)
templateVersion$ = "2"
wordVersion$ = "MacWord2016"
wordAppPath$ = AppleScriptTask("Zotero.scpt", "getPath", "")
wordAppPath$ = Replace(wordAppPath$, " ", "%20")
#If VBA6 Then
Dim majorVersion As Integer
majorVersion = Split(Application.Version, ".")(0)
If majorVersion >= 16 Then
wordVersion$ = "MacWord16"
End If
#End If
httpShellScript$ = "curl -s -o /dev/null -I -w '%{http_code}' -X GET '" & zoteroUrl & "agent=" & wordVersion$ & "&command=" & func & "&document=" & wordAppPath$ & "&templateVersion=" & templateVersion$ & "' | grep -q '200' || exit 1"
Result$ = AppleScriptTask("Zotero.scpt", "callZotero", httpShellScript$)
End Sub
You probably have users where you need to use
MacScript
? But generally what can be done withAppleScriptTask
should be done withAppleScriptTask
instead..?We need to use both
MacScript
andAppleScriptTask
because some people get run-time error 5 with one, and some, with other. We only added the use ofAppleScriptTask
a couple of years back and before that we used to get quite a few run-time error 5 reports that we have managed to reduce. Initially we tried using onlyAppleScriptTask
, but apparently that causes run-time error 5 for more users thanMacScript
.(on first try I encountered a problem, seemed to have been a fluke but just FYI: after clicking/running Insert Citation the
AppleScriptTask
call led to word becoming unresponsive (needed to force quit), and, when the ScriptEditor was also open, it also froze this app. Can't reproduce and seems to be a macOS issue, or some larger issue, anyway.)We're still investigating the reports of new delays while using the plugin. Follow the other thread for updates.
Were you using the Word plugin previously on this computer?
I checked and I have Zotero 6.0.28 installed. The Zotero standalone app lists the version of the Zotero add-on as 6.0.10.SA.6.0.30. I am using Microsoft Word 16.78.3 (23102801) with an Office Home & Student 2021 license. I am currently running macOS Sonoma 14.1.1 (23B81) on a personal MacBook Pro 2019 with built-in Retina display and an Intel chip. I am not running any security software besides what comes standard with the MacBook Pro, and my MacBook has not indicated the activation of any security features recently. I have very little familiarity with how Visual Basic works, so I'm afraid I cannot be of much help on that front.
Make sure you're running 6.0.30, go to your Word Startup folder, delete Zotero.dotm, restart Word, and confirm that Zotero is completely gone from Word. Then follow the steps under Zotero Toolbar Doesn't Appear to reinstall the plugin.
And I've already done what you said in the second paragraph, to no avail.
I have the latest word and the latest zotero. I've tried deleting the dotm, replacing it with the versions above, deleting again and reinstalling. Still error 5 when I try to insert a citation...