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....
Bookmarks