Excel continue de s'exécuter en background après la fin de la macro qui le contrôle.
Bonjour,
Je suis débutant en VBA.
En cherchant, j'ai vu qu'il fallait accéder à tout objet en le déclarant en tant que variable d'abord et ce même pour les collections. Il faut les libérer ensuite et c'est ce que je pense faire, mais excel ne se termine pas.
Cela est ennuyeux et le tuer en tant que processus est dangereux car s'il y a une autre instance lancée...
Merci de m'aider à trouver une solution.
Code:
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
|
Dim oExcel As Object
Dim oWorkbooks As Object
Dim oWorkbook As Object
Dim oSheet As Object
Set oExcel = New Excel.Application
oExcel.Visible = True
Set oWorkbooks = oExcel.Workbooks
Set oWorkbook = oWorkbooks.Open("C:\Test.xlsm", ReadOnly:=True)
Dim oSheets As Object
Set oSheets = oWorkbook.Sheets
Set oSheet = oSheets(1)
Dim myRange As Object
Set myRange = oSheet.Range("A:A")
Dim oWorksheetFunction As Object
Set oWorksheetFunction = Excel.WorksheetFunction
MsgBox oWorksheetFunction.CountIf(myRange, "*")
oWorkbook.Close
CleanUp:
Set oWorksheetFunction = Nothing
Set myRange = Nothing
Set oSheet = Nothing
Set oSheets = Nothing
Set oWorkbook = Nothing
Set oWorkbooks = Nothing
oExcel.Quit
Set oExcel = Nothing |