XL pour MAC remplacer GetOpenFilename pour macro sur mac

sylvian

XLDnaute Nouveau
bonjour,
on viens de me faire une Macro (merci encore ) mais la personne n'a pas de mac et GetOpenFilename ne fonctionne pas sur Mac
Quelqu'un aurait il cette fonction pour Mac en rouge:

Sub Import()
Dim WkImp As Workbook
Dim shImp As Worksheet, shRecep As Worksheet
Set shRecep = Workbooks(ThisWorkbook.Name).Worksheets(1)
strFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xl*),*.xl*")
If strFile = False Then MsgBox "Aucun fichier sélectionné": Exit Sub
Workbooks.Open Filename:=strFile
Set WkImp = ActiveWorkbook
NomFichier = ActiveWorkbook.Name
Set shImp = Workbooks(NomFichier).Worksheets(1)
DLigImp = shImp.Range("A65536").End(xlUp).Row
DLigRecep = shRecep.Range("A65536").End(xlUp).Row + 1
For ind = 1 To DLigImp
'1ère col fichier import
If shImp.Cells(ind, 4) <> 0 Then
shRecep.Cells(DLigRecep, 1) = shImp.Cells(ind, 1)
shRecep.Cells(DLigRecep, 4) = shImp.Cells(ind, 2) & " " & shImp.Cells(ind, 3)
If shImp.Cells(ind, 4) < 0 Then
Nega = 1
shRecep.Cells(DLigRecep, 5) = shImp.Cells(ind, 4) * -1
Else
shRecep.Cells(DLigRecep, 6) = shImp.Cells(ind, 4)
End If
DLigRecep = DLigRecep + 1
shRecep.Cells(DLigRecep, 1) = shImp.Cells(ind, 1)
shRecep.Cells(DLigRecep, 4) = shImp.Cells(ind, 2) & " " & shImp.Cells(ind, 3)
If Nega = 1 Then
shRecep.Cells(DLigRecep, 6) = shImp.Cells(ind, 4) * -1
Else
shRecep.Cells(DLigRecep, 5) = shImp.Cells(ind, 4)
End If
End If
'=====================
'2ème col fichier import

Nega = 0
Posit = 0
If shImp.Cells(ind, 5) <> 0 Then
DLigRecep = DLigRecep + 1
shRecep.Cells(DLigRecep, 1) = shImp.Cells(ind, 1)
shRecep.Cells(DLigRecep, 4) = shImp.Cells(ind, 2) & " " & shImp.Cells(ind, 3)
If shImp.Cells(ind, 5) < 0 Then
Nega = 1
shRecep.Cells(DLigRecep, 6) = shImp.Cells(ind, 5) * -1
Else
shRecep.Cells(DLigRecep, 5) = shImp.Cells(ind, 5)
End If
DLigRecep = DLigRecep + 1
shRecep.Cells(DLigRecep, 1) = shImp.Cells(ind, 1)
shRecep.Cells(DLigRecep, 4) = shImp.Cells(ind, 2) & " " & shImp.Cells(ind, 3)
If Nega = 1 Then
shRecep.Cells(DLigRecep, 5) = shImp.Cells(ind, 5) * -1
Else
shRecep.Cells(DLigRecep, 6) = shImp.Cells(ind, 5)
End If
End If
Nega = 0
Posit = 0
DLigRecep = DLigRecep + 1

Next ind
MsgBox "Import terminé"
WkImp.Close
End Sub


merci a tous

sylvian
 

job75

XLDnaute Barbatruc
Bonjour sylvian,

Je ne sais pas si les Application.Dialogs fonctionnent sur MAC, testez avec :
VB:
Sub Test()
Dim wb As Workbook
If Application.Dialogs(xlDialogOpen).Show Then
    Set wb = ActiveWorkbook
    MsgBox wb.Name 'pour tester
End If
End Sub
Différence importante : avec GetOpenFilename on n'est pas obligé d'ouvrir le fichier choisi.

A+
 

job75

XLDnaute Barbatruc
Dans votre macro il suffit de remplacer ces 3 lignes :
VB:
strFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xl*),*.xl*")
If strFile = False Then MsgBox "Aucun fichier sélectionné": Exit Sub
Workbooks.Open Filename:=strFile
par cette ligne unique :
VB:
If Not Application.Dialogs(xlDialogOpen).Show Then MsgBox "Aucun fichier sélectionné": Exit Sub
 

Statistiques des forums

Discussions
312 299
Messages
2 086 997
Membres
103 424
dernier inscrit
Kyuubi