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

rccharles

New Member
Joined
Jul 30, 2019
Messages
4
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*)
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top