Run-time error'5' once more (2023)

  • 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 = "";
    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 = ""; & DataLine & "/integration/macWordCommand?"
    End If
    End If

    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 with AppleScriptTask should be done with AppleScriptTask instead..?
  • Does this Zotero.dotm work?

    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.
  • Yes! That one works. Thank you so much!

    (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.)
  • edited October 11, 2023
    (actually, the "fluke" that I encountered with the new dotm sounds a lot like what others have described here)
  • We've just released Zotero 6.0.28 with a fix for the Run-time Error '5' issue. @jhimmelreich, thanks for all your help debugging this.

    We're still investigating the reports of new delays while using the plugin. Follow the other thread for updates.
  • thank you for spending so much time on this edge case. just updated and works like a charm
  • my system updated it to version 6.0.28 and it is giving me the issue when trying to use it with Word. Any thoughts or help? Thank you.
  • @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.
  • Thank you. It appears fine after I do that, but it still gives me the runtime error.
  • edited October 13, 2023
    Is this an institutional computer?

    Were you using the Word plugin previously on this computer?
  • my own personal laptop. was fine until the version got updated from .26 to .28
  • Do you run any security software on your computer? Have you tried disabling it temporarily?
  • @dgehry: Also, what version of macOS is this?
  • 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.
  • @dstillman I checked and I do indeed have Zotero 6.0.30 installed.

    And I've already done what you said in the second paragraph, to no avail.
  • @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...
Sign In or Register to comment.