0
votes

I am trying to update a template for Word 2016 for Mac.

In the prior code, I was able to run MacScript() command to run an AppleScript that in turn ran a shell script.

It appears the only way now to run such a script is to use AppleScriptTask, which requires that the script exists already in Application Scripts folder, which presents problems when I'm trying to distribute this to other (non-savvy) users.

I'm trying to figure out alternative ways of doing this, but after weeks of research, I am still stumped.

The scripts I'm running do various things, but the most important right now is to download updated versions of the template from a website. I use ActiveX on the Windows side to do this, but can't do that on Mac.

Can anyone suggest any alternative approaches for Mac Word 2016, using VBA (only preferably)?

Thank you!

2
I used Rich’s suggestion below. It works well. I have it download to the default Downloads folder then move it where I need it (with VBA). - johnwangel

2 Answers

1
votes

Try this:

ActiveDocument.FollowHyperlink "http://yoursite.com/yourpackage.zip"
0
votes

Below is what I did to accomplish this. I set a timer to wait on the download, since it's being done outside of VBA.

Function Download(Path As String) As String

On Error GoTo Handler
Dim User, UserPath, dlFile, base_dest, final_dest, FName As String
Dim Timer As Boolean
Timer = False
Dim timeout As Variant

timeout = Now + TimeValue("00:00:10")
User = Environ("USER")
UserPath = "/Users/" & User & "/Downloads/"
base_dest = "/Users/" & User & [move/path/]
final_dest = base_dest & FName
ActiveDocument.FollowHyperlink Address:=Path

If Dir(final_dest) <> "" Then
    Kill final_dest
End If

Timer = True
ReTry:
If Dir(dlFile) <> "" Then
    FileCopy dlFile, final_dest
    Kill dlFile
    Download = final_dest
    Exit Function
End If

Handler:
If Err.Number = 53 And Timer = False Then
    Resume Next
 ElseIf Err.Number = 53 And Timer = True Then
    If Now > timeout Then
        MsgBox "There is a problem downloading the file. Please check your internet connection."
        End
    Else
        Resume ReTry
    End If
Else
    MsgBox Err.Number & vbNewLine & Err.Description
    End
End If
End Function