+ Reply to Thread
Results 1 to 3 of 3

MAC - applescripttask - browse and open a file

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    Rome, Italy
    MS-Off Ver
    365
    Posts
    2

    MAC - applescripttask - browse and open a file

    Here is my problem: I've a macro that should work both on MAC e windows.
    On MAC it should work both on old excel versions and on new ones (2016 and up).
    As Ron De Bruin teack us for 2016 and up I need to use AppleScriptTask.

    My problem in on 2016 and up: i want that the macro opens the finder, the user browses and chooses a file, than I've to get the file name and path and use these information in the rest of the code.

    To check the version I use this function - it works, i just insert it in order to be complete:
    Function Versione_Mac_office() As String
    #If Mac Then
    #If MAC_OFFICE_VERSION >= 15 Then
    Versione_Mac_office = "15+"
    #Else
    Versione_Mac_office = "15-"
    #End If
    #Else
    Versione_Mac_office = "NO"
    #End If
    End Function

    Then i execute different code based on the result; for MAC with new version of office I used

    If Versione_Mac_office = "15+" Then 'è MAC con office 365
    OpenFolderInFinder
    End If

    I've copied from Ron de Bruin this function:
    Sub OpenFolderInFinder()
    Dim RunMyScript As String
    Dim FolderPath As String
    On Error Resume Next
    FolderPath = MacScript("return POSIX path of (path to Desktop) as string")
    RunMyScript = AppleScriptTask("FileFolder.scpt", "OpenFolder", FolderPath)
    If RunMyScript = "Error" Then
    MsgBox "Wrong folder path"
    End If
    End Sub

    FileFolder.scpt is this one:

    on OpenFolder(folderPath)
    if ExistsFolder(folderPath) = true then
    do shell script "open " & quote & folderPath & quote
    else
    return "Error"
    end if
    end OpenFolder

    on ExistsFolder(folderPath)
    tell application "System Events" to return (exists disk item folderPath) and class of disk item folderPath = folder
    end ExistsFolder

    But this just open the finder and then the VBA code proceeds without waiting for the user to choose a file and does not get the file mane and path

    Really need help! Thanks....

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: MAC - applescripttask - browse and open a file

    That's not the routine you need. You should look at this page: https://www.macexcel.com/examples/fi...s/selectfiles/
    Rory

  3. #3
    Registered User
    Join Date
    01-03-2020
    Location
    Rome, Italy
    MS-Off Ver
    365
    Posts
    2

    Re: MAC - applescripttask - browse and open a file

    Well thanks a lot you saved me!

    See you in my future questions have a nice day

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. File>Open>make Browse the default
    By grannash in forum Excel General
    Replies: 4
    Last Post: 09-21-2018, 02:29 PM
  2. [SOLVED] Browse and open file thro VBA
    By shreeja178 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2015, 05:49 AM
  3. Browse for a file and embed it in a userform to open in the future
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2014, 03:07 AM
  4. Get VBA to allow user to Browse for a file to open
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2012, 05:52 AM
  5. Browse for File to open
    By RobynC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2007, 07:30 AM
  6. FIle Open/Browse on Macintosh
    By TooTall in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 03:05 PM
  7. File Browse Function (Open dialog box for choosing file)
    By b-123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2005, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1