MacScript calll with  POSIX path of  filename fails in  2011 vba macro
Results 1 to 2 of 2

Thread: MacScript calll with POSIX path of filename fails in 2011 vba macro
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default MacScript calll with POSIX path of filename fails in 2011 vba macro

    I running on macOS 10.10.5 with Office 2011. I'm having a problem with this macro. I cannot get MacScript to return the POSIX path of a mac file path.

    Code:
    Sub tryOut()
    Dim cValue As String
    Dim thePath As String
    Dim allData As String
    Dim unixDesktopPath  As String
        Debug.Print "----------------------------" & Now
    
        cValue = "1.jpg"
        thePath = MacScript("return (path to desktop folder) as String")
        Debug.Print "thePath is " & thePath
        allData = "return ( POSIX path of "
        allData = allData & """"
        allData = allData & thePath & "numbers:" & cValue
        allData = allData & """ ) as String"
        Debug.Print "allData is " & allData
        ' next statement fails :-(
        unixDesktopPath = MacScript(allData)
        Debug.Print "unixDesktopPath = " & unixDesktopPath
    End Sub 'tryOut
    Here is the immediate output.

    Code:
    ----------------------------7/29/2019 11:10:45 PM
    thePath is Macintosh SSD:Users:mac:Desktop:
    allData is return ( POSIX path of "Macintosh SSD:Users:mac:Desktop:numbers:1.jpg" ) as String
    This statement works as expected in applescript

    Code:
    log POSIX path of "Macintosh SSD:Users:mac:Desktop:numbers:1.jpg"
    Code:
    (*/Users/mac/Desktop/numbers/1.jpg*)

  2. #2
    Board Regular
    Join Date
    Jul 2011
    Location
    Buffalo, NY
    Posts
    237
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MacScript calll with POSIX path of filename fails in 2011 vba macro

    When I ran your code I did not get an error. Here is my output (using a file called Picture1.jpg)
    Code:
    ----------------------------8/19/19 12:53:17 PM
    thePath is Macintosh HD:Users:libjbg:Desktop:
    allData is return ( POSIX path of "Macintosh HD:Users:libjbg:Desktop:numbers:Picture1.jpg" ) as String
    unixDesktopPath = /Users/libjbg/Desktop/numbers/Picture1.jpg
    I am using Office 2019 Excel version 16.29

    Excel 2011 does not run in Mac OS X Catalina, so I can't test the old 2011 version any more.
    Last edited by Jim Gordon Mac MVP; Aug 19th, 2019 at 12:58 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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