Communication VBA entre 2 fichiers excel
Bonjour à toutes et à tous
Je sollicite votre aide pour me sortir d'affaire
J'ai un fichier A qui possède une commande bouton affectée à un code qui ouvre un fichier B fermé. .
Puis une fois que j'ai accompli mes taches dans B, un bouton dans B ré ouvre A et B se ferme en enregistrant.
C'est là ou tout se gâte, je ne peux plus retourner sur le fichier B. Dés que j'appuie sur le bouton Excel crash.
Procédure : A ouvre B puis A se Ferme. B ré ouvre A puis B se ferme en enregistrant...... Ainsi de suite
Je vous joins mes codes pour compléter mes explications.
Dans le fichier A
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Sub ouvrirB()
Application.ScreenUpdating = False
Dim chemin As String
Application.WindowState = xlMinimized
chemin = ThisWorkbook.Path
On Error Resume Next
Workbooks.Open Filename:=chemin & "\" & Sheets("MENU").Range("J11").Value & "B.xlsm"
Sheets("SAISIE").Activate
Application.WindowState = xlMaximized
Application.DisplayAlerts = False
Workbooks(Sheets("MENU").Range("J11").Value & "A.xlsm").Close False
Application.ScreenUpdating = True
On Error GoTo 0
End Sub |
Dans le fichier B
Code:
1 2 3 4 5 6 7 8 9 10
| Sub OuvrirA()
Application.ScreenUpdating = False
On Error Resume Next
chemin = ThisWorkbook.Path
Workbooks.Open Filename:=chemin & "\" & Sheets("MENU").Range("J11").Value & "A.xlsm"
Sheets("MENU").Select
Application.DisplayAlerts = False
Workbooks(Sheets("MENU").Range("J11").Value & "B.xlsm").Close True
Application.ScreenUpdating = True
End Sub |