Bonjour a tous,

J'ai un souci avec excel 2007 lors d'un lancement de macro d'un autre fichier par code.

J'utilisais dans la version 2003 de mon fichier la commance : "Application.Run".
Sous 2003 tout fonctionne très bien.
Sous 2007 tout foncionne très bien si je lance le code d'un fichier au format 2003 (xls). Si je veux lancer le code d'un fichier xlsm, j'ai un run-time '1004'.

J'avoue ne pas comprendre l'origine de mon erreur.

Je me permet de mettre le code utilisé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
Sub OuvreLeEtLanceLaMacro()
Dim fso As New FileSystemObject, fsoFile As File
Dim wbMonAuterFichier As Workbook
Dim stMonCheminEtFichier As String
 
stMonCheminEtFichier = "c:\Monchemin\fichier.xlsm"
'stMonCheminEtFichier = "c:\Monchemin\fichier.xls"
 
'Etape 1 : tester l'existance
If fso.FileExists(stMonCheminEtFichier) Then
 
  Set fsoFile = fso.GetFile(stMonCheminEtFichier)
  'Etape 2: Est il deja ouvert? si non ouvrir / si oui le prendre
  Set wbMonAuterFichier = Application.Workbooks.Open(stMonCheminEtFichier, False, False, , , , True)
 
  'Etapa 3: rafraichir 
  wbMonAuterFichier.Sheets("Menu").Calculate
 
  'Etape4: lancer la macro
  Application.Run fsoFile.Name & "!" & "Module.Macro1"
 
  Set fsoFile = Nothing
End If
 
Set fso = Nothing
 
End Sub