Share via

Issues with applescript

Anonymous
2016-12-31T21:40:16+00:00

Hello,

I'm having issues with Applescript working properly for a number of commands...

Here are some examples:

tell application "Microsoft Word"

execute find find text "hello"

end tell

The resulting response is: 

error "Microsoft Word got an error: Can’t continue execute find." number -1708

Another example:

tell application "Microsoft Word" to page scroll down 1

And the result:

error "Microsoft Word got an error: Can’t continue page scroll." number -1708

Does anyone have an idea what is going on? Is my applescript incorrect or am I missing something else?

Thank you,

Harold

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2017-01-03T07:40:42+00:00

    Hi Hpimentel,

    Thanks for your update.

    Based on our initial troubleshooting, the issue may be related to the argument when calling AppleScriptTask from VB.

    Since you have posted to “Office/Word/Mac/Office 2016 for mac” category which mainly focuses on general Word functional use related queries, I’m going to move this thread to the “Office /Word /Microsoft Office programming  /Office 2016” category for proper handing.

    We appreciate your understanding.

    Sky

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-01-03T01:51:03+00:00

    Hello Sky,

    Thank you for the response. Unfortunately, I still get the same result after fixing that variable.

    I'm fairly certain the error is in the call to 'tell application "Microsoft Word"...' as when I remove that call, the script runs correctly. However, after looking at the Applescript dictionary, that looks like the correct call.

    Any other suggestions?

    Thank you,

    Harold

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-01-02T12:06:20+00:00

    Hi Hpimentel,

    Regarding "Dim myScriptResult as string" ,  the string should be replaced by Boolean.  Please  edit your code as the following format to see the result.

    Thanks,

    Sky

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-01-01T00:09:08+00:00

    Thank you very much Rich.

    If I understand correctly, in order to call some of the commands from the Microsoft Word applescript dictionary (such as page scroll), I need to do the following:

    • Create a applescript and place it in ~/Library/Application\ Scripts/com.microsoft.Word Here is where I would have 1 of the scripts that I posted in the initial question.
    • Create a new macro within Word that calls that specific script using AppleScriptTask such as the following:

    Sub hello()

        Dim myScriptResult As String

        myScriptResult = AppleScriptTask("pagescroll.scpt", "myapplescripthandler", "my parameter string")

    End Sub

    Now, I should be able to in principle call this macro within Word and it should just work...

    However, when calling with the following applescript:

    on myapplescripthandler(paramString)

    #do something with paramString 

    tell application "Microsoft Word" to page scroll down 1

    display notification paramString

    return "You told me " & paramString

    end myapplescripthandler

    I get the following error in the image attached:

    If I remove the page scroll command, then I can successfully get the notification to show up. Otherwise, I get the previous error.

    Any suggestions?

    Thanks in advance,

    Harold

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-12-31T21:55:43+00:00

    With Mac Office 2016 a new problem has been introduced called "Sandboxing" and this directly effects how and what former AppleScripts can and will work now.

    From the link I have provided, take a look at Ron's website for information on how to deal with this... Ron is and Excel MVP but the methods he shares apply to Microsoft Word as well.

    http://www.rondebruin.nl/mac/applescripttask.htm

    Hope this helps

    Was this answer helpful?

    0 comments No comments