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*)
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Jim Gordon Mac MVP

Board Regular
Joined
Jul 22, 2011
Messages
240
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:

Watch MrExcel Video

Forum statistics

Threads
1,102,679
Messages
5,488,226
Members
407,632
Latest member
varunwalla

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top