Hi! All new to me. Never wrote a Mac script. On Mac OS X 10.6.8, Apple script 2.1.2, and Excel 2011 14.0.0 for Mac. Did not find an answer on Ron DeBruin automation site dedicated to Excel (Win & Mac).
In VBA:
Dim strDefaultSearchPath As String
Dim strScrOpenFilesOutput As String
Dim strFileDateTime As String
Dim macscriptGetFilenamesToOpen As String
Dim macscriptGetFiledatetimeOfModification As String
… some other VBA code
’ From Ron DeBruin
macscriptGetFilenamesToOpen = _
“set applescript’s text item delimiters to “”,”" " & vbNewLine & _
“set theFiles to (choose file of type " & _
" {”“com.microsoft.excel.xlsx”“,”“com.microsoft.excel.xlsm”“,”“public.comma-separated-values-text”“} " & _
“with prompt ““Choisir une seule liste CSV”” default location alias “”” & _
strDefaultSearchPath & “”” multiple selections allowed false) as string" & vbNewLine & _
“set applescript’s text item delimiters to “””" " & vbNewLine & _
“return theFiles”
’ My unfortunate guess, because “FileDateTime()” works on Win/Excel, but not on Mac/Excel
macscriptGetFiledatetimeOfModification = _
"set theFileFullPath to (((strScrOpenFilesOutput) as text) & ““speed.txt””) " & vbNewLine & _
"tell application ““Sytem Events”” to set theModDate to modification date of file theFileFullPath " & vbNewLine & _
“return theModDate”
… some other VBA code
strDefaultSearchPath = Application.DefaultFilePath
strScrOpenFilesOutput = MacScript(macscriptGetFilenamesToOpen) ’ This one works like a charm
strFileDateTime = MacScript(macscriptGetFiledatetimeOfModification) ’ This one returns Error 5:
… some other VBA code
At first, it popped a dialog asking where “System Events” was, and I picked the System Events.app from the list.
Then, Error 5, in French, is: Argument ou appel de procédure incorrect
Explicit help appreciated, as Mac scripting is all new to me.
Thank you.
Model: MacBook Pro
AppleScript: Apple script 2.1.2
Browser: Safari 534.59.10
Operating System: Mac OS X (10.6)