Run-time error'5' once more (2023)
Hi
After Zotero re-installed the word plugin this morning, I'm suddenly getting the VBA runtime error 5 as discussed previously. Worked fine last night.
Following the instructions by @adomasven here, the error can be traced to the line
When I replace this line with an innocuous MsgBox, the same error is traced to the next line with a MacScript command ("MacScript "try" & nl$ & "do shell script..").
I am surprised the MacScript command is still in there given that it is deprecated since 2021?
Zotero 6.0.27 (syncing with Zotero 7 beta on other machines)
Word 16.76.1
macOS 13.5.1
Any ideas?
Thanks
J
After Zotero re-installed the word plugin this morning, I'm suddenly getting the VBA runtime error 5 as discussed previously. Worked fine last night.
Following the instructions by @adomasven here, the error can be traced to the line
wordAppPath$ = Replace(MacScript("POSIX path of (path to current application)"), " ", "%20")
When I replace this line with an innocuous MsgBox, the same error is traced to the next line with a MacScript command ("MacScript "try" & nl$ & "do shell script..").
I am surprised the MacScript command is still in there given that it is deprecated since 2021?
Zotero 6.0.27 (syncing with Zotero 7 beta on other machines)
Word 16.76.1
macOS 13.5.1
Any ideas?
Thanks
J
https://forums.zotero.org/discussion/107566/urgent-word-crashing-post-zotero-word-plugin-update
https://forums.zotero.org/discussion/107563/zotero-integration-error-after-repeated-troubleshooting
https://forums.zotero.org/discussion/107540/word-document-disappears-every-time-i-add-zotero-citation
https://forums.zotero.org/discussion/comment/442902/#Comment_442902
https://forums.zotero.org/discussion/107537/word-document-se-cierra-cuando-interatuo-con-zotero
Does this go away if you switch back to Zotero 6.0.26 from the download page?
Specifically, you can tell your IT department that the 6.0.27 plugin uses
curl
to make an HTTP request to the Zotero app at127.0.0.1:23119
(since Sonoma blocks the previous communication method). Hopefully they'll be able to figure out from that what on the system would be blocking that from running.➡️ Using the .26 version of the dotm, inserting citations works both with the .26 and the .27 app version.
➡️ Using the .27 version of the dotm, inserting citations works with neither with the .26 and the .27 app version.
I also tried the alternative .dotm linked to in the other discussion. Behaves like .27 dotm, i.e., error in both Zotero app versions.
Using the .27 with the older .26 plugin generated the warning about the outdated plugin but it seemed to execute just fine.
Hope that helps
J
wordAppPath$
, we don't seem to get to the line that runscurl
./Applications/Microsoft Word.app
?wordAppPath$ = MacScript("POSIX path of (path to current application)")
Sub Test()
MacScript ("beep")
End Sub
try
do shell script "curl -s -o /dev/null -I -w '%{http_code}' -X GET http://127.0.0.1:23119/integration/macWordCommand?&agent=MacWord16&command=addCitation&document=/Application/Word.app&templateVersion=2 | grep -q '200' || exit 1"
on error
display alert "failed" as critical
end try
I get the "Zotero Integration Error" ("Zotero could not load the component necessary to communicate with your word processor. Go to Tools → Add-ons → Extensions in Zotero and make sure that the extension for your word processor is enabled")
MacScript
, so what you're seeing here is truly bizzare.Does
osascript
command in the terminal to run AppleScript work for you?osascript -e beep
for example works as intended.Btw: Apparently a few people here had a runtime error 5. For most the solution was to re-install the word add-in. But there seems to be at least another person here who, like me, has a persistent runtime error 5 with version .27.
MacScript ("beep")
right in the first line afterSub CallZotero(func)
I get the runtime error 5 even in Zotero .26 version of the add-in (which works otherwise). So why does the procedure not break elsewhere in the same VBA module?MacScript
call causes a runtime error, but since it is within the error handling routineOn Error GoTo catch
the script then jumps tocatch:
and the code block following this line label is executed and provides the functionality of the the add-in.In short, it seems that also in the .26 version of the add-in the
MacScript
causes a runtime error but the add-in works regardless.In the .27 derivative dotm, the error handling might be part of the issue.
One thought: The code following the
catch:
label in the dotm you linked to uses theMacScript
procedure. That means that the code that is run in case of a runtime error includes a procedure call that likely causes the same runtime error. — As mentioned in previous post, both the .26 add-in and the .27 add-in encounter runtime error 5. The add-in of version .26 works despite theMacScript
call not because of it (because the .26 error handling code provides the functionality).Another thought: In the dotm you linked to, there are two error handlers in the same function. I don't think I fully get how VBA handles this. Could the first one
On Error GoTo customUrlNotSet
interfere with the second oneOn Error GoTo catch
? Perhaps, because the first error handler is still active, the code block following the line labelcatch:
is never executed although (on an "intuitive" reading of the code) you'd expect it would be on a runtime error in the immediately preceding block.In sum, it seems to me that the main difference why the .26 add-in does work and the .27 (or the derivative version you sent) doesn't is that the .26 version uses the
AppleScriptTask
procedure following thecatch:
in case of an error.Can you place this Zotero.scpt file at
~/Library/Application Scripts/com.microsoft.Word
, then try this Zotero.dotm file with Zotero 6.0.27?MacScript
that iswordAppPath$ = Replace(MacScript("POSIX path of (path to current application)"), " ", "%20")
But I am not sure I got the right Zotero.dotm. It still uses
AppleScriptTask
nowhere, if that was the intention; and has two error handlers and usesMacScript
even incatch:
block.Zotero.scpt
Zotero.dotm
MacScript "try" & nl$ & "do shell script """ & httpShellScript$ & """" & nl$ & "on error" & nl$ & "display alert """ & onFailMessage$ & """ as critical" & nl$ & "end try"
The error handler doesn't seem to work. This line that causes the error comes right after
On Error GoTo catchMacScriptHttp
. Although there is a runtime error, VBA does not jump tocatchMacScriptHttp:
. See my comments above about the VBA trickiness of having more than one error handler within aSub
.Result$ = AppleScriptTask("Zotero.scpt", "callZotero", httpShellScript$)
GoTo endSub
Specifically, in the dotm you linked to right above, by just deleting the code block following
On Error GoTo catchMacScriptHttp
I got the add-in to work. The subsequent lines inResult$ = ...
provided the functionality (at least for inserting citations).In short: Use
AppleScriptTask
notMacScript
and don't use more than one error handler in oneSub
and at least the problem that I faced should be solved.To get the same functionality that you want to get with the different error handlers with only one
OnError
you might be able to set custom error codes and useSelect Case
to implement the intended behavior similar to what is described hereJust a note to say I am also having this problem
Zotero 6.0.27
Word 16.77.1
macOS Ventura 13.3.1 (M1 Chip)
It seems like you are close to a solution? Would you mind posting a summary of the fix, if there is one?
https://forums.zotero.org/discussion/108323/run-time-error-5-in-word-for-mac#latest
We're debugging this in this thread and should have a fix soon.
MacScript
). Problem is still that the error handler doesn't work as it seems to be intended. It doesn't jump tocatchMacScriptHttp: