Il ne faut pas faire une version mac et une windows. Il faut faire qqchose qui marche sur les deux
Function isMac() As Boolean
If Application.OperatingSystem Like "*Mac*" Then
isMac = True
Else
isMac = False
End If
End Function
Function myGetOpenFileName(Optional sPath As String) As String
Dim sFile As String
Dim sMacScript As String
If isMac Then
If sPath = vbNullString Then
sPath = "the path to documents folder"
Else
sPath = " alias """ & sPath & """"
End If
sMacScript = "set sFile to (choose file of type ({" & _
"""com.microsoft.Excel.xls"", ""org.openxmlformats.spreadsheetml.sheet""," & _
"""public.comma-separated-values-text"", ""public.text"", ""public.csv""," & _ """org.openxmlformats.spreadsheetml.sheet.macroenabled""}) with prompt " & _
"""Select a file to import"" default location " & sPath & ") as string" _
& vbLf & _
"return sFile"
Debug.Print sMacScript
sFile = MacScript(sMacScript)
Else 'windows
sFile = Application.GetOpenFilename("CSV files,*.csv,Excel 2007 files,*.xlsx", 1, _
"Select file to import from", "&Import", False)
End If
myGetOpenFileName = sFile
End Function