Fermer Excel.exe complètement.

tatayoyo38

XLDnaute Nouveau
Bonjour,
J'utilise ce code pour fermer Excel :

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

ActiveWindow.DisplayGridlines = True
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayWorkbookTabs = True
Application.DisplayFullScreen = False

Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.WindowState = xlMaximized
Application.ScreenUpdating = True

Application.Quit

End Sub

Surtout la derniere ligne en fait.
Seul soucit, il reste afficher dans mon Task Manager et comme je lance excel via un fichier bat le fichier bat ne peut pas continuer car il attend la fermeture de excel.

Comment faire ?
Merci a tous.
 

Staple1600

XLDnaute Barbatruc
Re : Fermer Excel.exe complètement.

Re



Essayes de modifier ta macro comme ci-dessous

Code:
ThisWorkbook.Saved = True 
Application.Quit

Pour lancer un batch nommé test.bat
Code:
Call Shell(Environ$("COMSPEC") & " /k C:\test.bat", vbNormalFocus)

'changer /k en /c si besoin
 
Dernière édition:

tatayoyo38

XLDnaute Nouveau
Re : Fermer Excel.exe complètement.

D'accord merci.

Edit

Code:
ChClose = ActiveWorkbook.Path & "\"
Call Shell(Environ$("COMSPEC") & ChClose & "Close.bat", vbNormalFocus)

J'ai essayer ca ca ne marche pas.

Ecit 2

J'ai fait ca : et ca marche :

Code:
ChClose = ActiveWorkbook.Path & "\"
Call Shell(ChClose & "Close.bat", vbNormalFocus)


Enfin, comment attribuer cette macro a un bouton ?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
 
Dernière édition:

Staple1600

XLDnaute Barbatruc
Re : Fermer Excel.exe complètement.

Re


Désolé mais ca marche :rolleyes:

Code:
Sub test()
Dim ChClose$
ChClose = ActiveWorkbook.Path & "\"
Call Shell(Environ$("COMSPEC") & " /k" & ChClose & "Close.bat", vbNormalFocus)
End Sub
EDITION: en cherchant un peu , (utilises le moteur de recherche du forum), tu trouveras comment associer une macro à un bouton, et comment utiliser les procédures évènementielles.
 
Dernière édition:

tatayoyo38

XLDnaute Nouveau
Re : Fermer Excel.exe complètement.

Quand je quitte excel, le Close.bat se lance et m'afficher ca :

'C:\Documents' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

Mon bat contient :

::mad:ECHO OFF
Taskkill /IM "MSOE03.EXE" /F /T
Pause
Exit

Je ne comprend pas ^^
 

tatayoyo38

XLDnaute Nouveau
Re : Fermer Excel.exe complètement.

ca ?

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

'ActiveWindow.DisplayGridlines = True
'ActiveWindow.DisplayHeadings = True
'ActiveWindow.DisplayHorizontalScrollBar = True
'ActiveWindow.DisplayWorkbookTabs = True
'Application.DisplayFullScreen = False

'Application.DisplayFormulaBar = True
'Application.DisplayStatusBar = True
'Application.WindowState = xlMaximized
'Application.ScreenUpdating = True
Debug.Print ChClose

'Dim ChClose$
'ChClose = ActiveWorkbook.Path & "\"
'Call Shell(Environ$("COMSPEC") & " /k" & ChClose & "Close.bat", vbNormalFocus)

'Application.Quit

End Sub

Je doit faire quoi ?
 
Dernière édition:

Statistiques des forums

Discussions
311 725
Messages
2 081 940
Membres
101 845
dernier inscrit
annesof