Au tout début de la procédure avant la ligne "On error resume next", ajoute
ces 2 lignes de code :
Application.EnableEvents = False
Application.ScreenUpdating = False
On Error Resume Next
...
With Application
...
.EnableEvents = False
.ScreenUpdating = False
Au tout début de la procédure avant la ligne "On error resume next", ajoute
ces 2 lignes de code :
Application.EnableEvents = False
Application.ScreenUpdating = False
On Error Resume Next
...
With Application
...
.EnableEvents = False
.ScreenUpdating = False
Au tout début de la procédure avant la ligne "On error resume next", ajoute
ces 2 lignes de code :
Application.EnableEvents = False
Application.ScreenUpdating = False
On Error Resume Next
...
With Application
...
.EnableEvents = False
.ScreenUpdating = False
Bonjour Isabelle, Je reviens sur cette procédure que tu m'avais
gentiment mise à disposition, car très efficace au début, elle à
beaucoup ralenti son temps d'exécution dernièrement (pour une raison
que j'ignore) et aujourd'hui elle "plante Excel" avec le message
d'erreur suivant: "Excel ne peut pas terminer cette tâche avec les
ressources disponibles. Sélectionnez moins de données ou fermez des
applications"
Evidemment cet avertissement n'est pas très explicite, car même Excel
seul (sans aucune autre application) dans Windows (7) le message
arrive et fini par planter. En réalité il y a en tout une trentaine
de fichiers que je "scanne" dans le répertoire et rapatrie les
items.
J'ai pensé que ce code doit partir en boucle quelque part, mais en le
passant en pas à pas, je ne le détecte pas. Bien que si je fais un
pas à pas énergique, il plante pareille.
Est-ce qu'un oeil expert saurait me dire comment lui donner un peu
d'oxygène, et agiliser son fonctionnement
'CODE: '--------------------------------------------------------- Sub
ListeProprietesFichiers_getDetailsOfTest() 'Nécessite d'activer la
référence Microsoft Shell Controls and Automation Dim objShell As
Shell32.Shell Dim strFileName As Shell32.FolderItem Dim objFolder As
Shell32.Folder Dim Resultat As String, Reponse As String Dim i As
Byte Dim x As Integer Dim Racine As String Dim MaCellule As String
On Error Resume Next MaCellule > ActiveCell.Address(RowAbsolute:úlse, ColumnAbsolute:úlse) With
Application .StatusBar = "Exécution macro...." .EnableEvents = False
.ScreenUpdating = False .DisplayAlerts = False End With Racine > ChoixDossierII() If Racine = "" Then Exit Sub Range("A:I").Clear
Range("A1").Select
Set objShell = CreateObject("Shell.Application") 'Répertoire cible
Set objFolder = objShell.Namespace(Racine)
'boucle sur tous les elements du repertoire For Each strFileName In
objFolder.Items
'la ligne 1 pour les titres de colonne If x <= 0 Then Cells(1, 1) > objFolder.GetDetailsOf(objFolder.Items, 0) Cells(1, 2) > objFolder.GetDetailsOf(objFolder.Items, 1) Cells(1, 3) > objFolder.GetDetailsOf(objFolder.Items, 3) Cells(1, 4) > objFolder.GetDetailsOf(objFolder.Items, 18) Cells(1, 5) > objFolder.GetDetailsOf(objFolder.Items, 20) Cells(1, 6) > objFolder.GetDetailsOf(objFolder.Items, 21) Cells(1, 7) > objFolder.GetDetailsOf(objFolder.Items, 22) Cells(1, 8) > objFolder.GetDetailsOf(objFolder.Items, 23) Cells(1, 9) > objFolder.GetDetailsOf(objFolder.Items, 24)
x = 1 End If
'Pour que les dossiers ne soient pas pris en comptes If
strFileName.isFolder = False Then 'Pour vérifier seulement les
fichiers Excel If Not IsError(Application.Find("Excel",
objFolder.GetDetailsOf(strFileName, 2))) Then x = x + 1 Cells(x, 1) > objFolder.GetDetailsOf(strFileName, 0) Cells(x, 2) > objFolder.GetDetailsOf(strFileName, 1) Cells(x, 3) > objFolder.GetDetailsOf(strFileName, 3) Cells(x, 4) > objFolder.GetDetailsOf(strFileName, 18) Cells(x, 5) > objFolder.GetDetailsOf(strFileName, 20) Cells(x, 6) > objFolder.GetDetailsOf(strFileName, 21) Cells(x, 7) > objFolder.GetDetailsOf(strFileName, 22) Cells(x, 8) > objFolder.GetDetailsOf(strFileName, 23) Cells(x, 9) > objFolder.GetDetailsOf(strFileName, 24) End If End If Next
Range(Selection, Selection.End(xlToRight)).Select With
Selection.Font .Name = "Verdana" .Size = 10 End With With
ActiveWindow .SplitRow = 1 .FreezePanes = True .DisplayGridlines > False End With Range(Selection, Selection.End(xlDown)).Select With
Selection .Locked = False .AutoFilter End With
Columns("A:H").AutoFit Columns("B:H").HorizontalAlignment = xlCenter
Columns("F:G").EntireColumn.Hidden = True With Application .Goto
Reference:¬tiveSheet.Range("A1"), scroll:=True
.Range(MaCellule).Select .DisplayAlerts = True .StatusBar = False
.EnableEvents = True .ScreenUpdating = True End With End Sub Function
ChoixDossierII() If Val(Application.Version) >= 10 Then With
Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName > "C:DocumentsMes Dossiers" .Show If .SelectedItems.Count > 0 Then
ChoixDossierII = .SelectedItems(1) Else ChoixDossierII = "" End If
End With Else ChoixDossierII = InputBox("Confirmer le répertoire?")
End If End Function
'--------------------------------------------------------- Merci
d'avance pour votre aide et éventuelles idées / solutions.
Cordialement,
Emile
Bonjour Isabelle, Je reviens sur cette procédure que tu m'avais
gentiment mise à disposition, car très efficace au début, elle à
beaucoup ralenti son temps d'exécution dernièrement (pour une raison
que j'ignore) et aujourd'hui elle "plante Excel" avec le message
d'erreur suivant: "Excel ne peut pas terminer cette tâche avec les
ressources disponibles. Sélectionnez moins de données ou fermez des
applications"
Evidemment cet avertissement n'est pas très explicite, car même Excel
seul (sans aucune autre application) dans Windows (7) le message
arrive et fini par planter. En réalité il y a en tout une trentaine
de fichiers que je "scanne" dans le répertoire et rapatrie les
items.
J'ai pensé que ce code doit partir en boucle quelque part, mais en le
passant en pas à pas, je ne le détecte pas. Bien que si je fais un
pas à pas énergique, il plante pareille.
Est-ce qu'un oeil expert saurait me dire comment lui donner un peu
d'oxygène, et agiliser son fonctionnement
'CODE: '--------------------------------------------------------- Sub
ListeProprietesFichiers_getDetailsOfTest() 'Nécessite d'activer la
référence Microsoft Shell Controls and Automation Dim objShell As
Shell32.Shell Dim strFileName As Shell32.FolderItem Dim objFolder As
Shell32.Folder Dim Resultat As String, Reponse As String Dim i As
Byte Dim x As Integer Dim Racine As String Dim MaCellule As String
On Error Resume Next MaCellule > ActiveCell.Address(RowAbsolute:úlse, ColumnAbsolute:úlse) With
Application .StatusBar = "Exécution macro...." .EnableEvents = False
.ScreenUpdating = False .DisplayAlerts = False End With Racine > ChoixDossierII() If Racine = "" Then Exit Sub Range("A:I").Clear
Range("A1").Select
Set objShell = CreateObject("Shell.Application") 'Répertoire cible
Set objFolder = objShell.Namespace(Racine)
'boucle sur tous les elements du repertoire For Each strFileName In
objFolder.Items
'la ligne 1 pour les titres de colonne If x <= 0 Then Cells(1, 1) > objFolder.GetDetailsOf(objFolder.Items, 0) Cells(1, 2) > objFolder.GetDetailsOf(objFolder.Items, 1) Cells(1, 3) > objFolder.GetDetailsOf(objFolder.Items, 3) Cells(1, 4) > objFolder.GetDetailsOf(objFolder.Items, 18) Cells(1, 5) > objFolder.GetDetailsOf(objFolder.Items, 20) Cells(1, 6) > objFolder.GetDetailsOf(objFolder.Items, 21) Cells(1, 7) > objFolder.GetDetailsOf(objFolder.Items, 22) Cells(1, 8) > objFolder.GetDetailsOf(objFolder.Items, 23) Cells(1, 9) > objFolder.GetDetailsOf(objFolder.Items, 24)
x = 1 End If
'Pour que les dossiers ne soient pas pris en comptes If
strFileName.isFolder = False Then 'Pour vérifier seulement les
fichiers Excel If Not IsError(Application.Find("Excel",
objFolder.GetDetailsOf(strFileName, 2))) Then x = x + 1 Cells(x, 1) > objFolder.GetDetailsOf(strFileName, 0) Cells(x, 2) > objFolder.GetDetailsOf(strFileName, 1) Cells(x, 3) > objFolder.GetDetailsOf(strFileName, 3) Cells(x, 4) > objFolder.GetDetailsOf(strFileName, 18) Cells(x, 5) > objFolder.GetDetailsOf(strFileName, 20) Cells(x, 6) > objFolder.GetDetailsOf(strFileName, 21) Cells(x, 7) > objFolder.GetDetailsOf(strFileName, 22) Cells(x, 8) > objFolder.GetDetailsOf(strFileName, 23) Cells(x, 9) > objFolder.GetDetailsOf(strFileName, 24) End If End If Next
Range(Selection, Selection.End(xlToRight)).Select With
Selection.Font .Name = "Verdana" .Size = 10 End With With
ActiveWindow .SplitRow = 1 .FreezePanes = True .DisplayGridlines > False End With Range(Selection, Selection.End(xlDown)).Select With
Selection .Locked = False .AutoFilter End With
Columns("A:H").AutoFit Columns("B:H").HorizontalAlignment = xlCenter
Columns("F:G").EntireColumn.Hidden = True With Application .Goto
Reference:¬tiveSheet.Range("A1"), scroll:=True
.Range(MaCellule).Select .DisplayAlerts = True .StatusBar = False
.EnableEvents = True .ScreenUpdating = True End With End Sub Function
ChoixDossierII() If Val(Application.Version) >= 10 Then With
Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName > "C:DocumentsMes Dossiers" .Show If .SelectedItems.Count > 0 Then
ChoixDossierII = .SelectedItems(1) Else ChoixDossierII = "" End If
End With Else ChoixDossierII = InputBox("Confirmer le répertoire?")
End If End Function
'--------------------------------------------------------- Merci
d'avance pour votre aide et éventuelles idées / solutions.
Cordialement,
Emile
Bonjour Isabelle, Je reviens sur cette procédure que tu m'avais
gentiment mise à disposition, car très efficace au début, elle à
beaucoup ralenti son temps d'exécution dernièrement (pour une raison
que j'ignore) et aujourd'hui elle "plante Excel" avec le message
d'erreur suivant: "Excel ne peut pas terminer cette tâche avec les
ressources disponibles. Sélectionnez moins de données ou fermez des
applications"
Evidemment cet avertissement n'est pas très explicite, car même Excel
seul (sans aucune autre application) dans Windows (7) le message
arrive et fini par planter. En réalité il y a en tout une trentaine
de fichiers que je "scanne" dans le répertoire et rapatrie les
items.
J'ai pensé que ce code doit partir en boucle quelque part, mais en le
passant en pas à pas, je ne le détecte pas. Bien que si je fais un
pas à pas énergique, il plante pareille.
Est-ce qu'un oeil expert saurait me dire comment lui donner un peu
d'oxygène, et agiliser son fonctionnement
'CODE: '--------------------------------------------------------- Sub
ListeProprietesFichiers_getDetailsOfTest() 'Nécessite d'activer la
référence Microsoft Shell Controls and Automation Dim objShell As
Shell32.Shell Dim strFileName As Shell32.FolderItem Dim objFolder As
Shell32.Folder Dim Resultat As String, Reponse As String Dim i As
Byte Dim x As Integer Dim Racine As String Dim MaCellule As String
On Error Resume Next MaCellule > ActiveCell.Address(RowAbsolute:úlse, ColumnAbsolute:úlse) With
Application .StatusBar = "Exécution macro...." .EnableEvents = False
.ScreenUpdating = False .DisplayAlerts = False End With Racine > ChoixDossierII() If Racine = "" Then Exit Sub Range("A:I").Clear
Range("A1").Select
Set objShell = CreateObject("Shell.Application") 'Répertoire cible
Set objFolder = objShell.Namespace(Racine)
'boucle sur tous les elements du repertoire For Each strFileName In
objFolder.Items
'la ligne 1 pour les titres de colonne If x <= 0 Then Cells(1, 1) > objFolder.GetDetailsOf(objFolder.Items, 0) Cells(1, 2) > objFolder.GetDetailsOf(objFolder.Items, 1) Cells(1, 3) > objFolder.GetDetailsOf(objFolder.Items, 3) Cells(1, 4) > objFolder.GetDetailsOf(objFolder.Items, 18) Cells(1, 5) > objFolder.GetDetailsOf(objFolder.Items, 20) Cells(1, 6) > objFolder.GetDetailsOf(objFolder.Items, 21) Cells(1, 7) > objFolder.GetDetailsOf(objFolder.Items, 22) Cells(1, 8) > objFolder.GetDetailsOf(objFolder.Items, 23) Cells(1, 9) > objFolder.GetDetailsOf(objFolder.Items, 24)
x = 1 End If
'Pour que les dossiers ne soient pas pris en comptes If
strFileName.isFolder = False Then 'Pour vérifier seulement les
fichiers Excel If Not IsError(Application.Find("Excel",
objFolder.GetDetailsOf(strFileName, 2))) Then x = x + 1 Cells(x, 1) > objFolder.GetDetailsOf(strFileName, 0) Cells(x, 2) > objFolder.GetDetailsOf(strFileName, 1) Cells(x, 3) > objFolder.GetDetailsOf(strFileName, 3) Cells(x, 4) > objFolder.GetDetailsOf(strFileName, 18) Cells(x, 5) > objFolder.GetDetailsOf(strFileName, 20) Cells(x, 6) > objFolder.GetDetailsOf(strFileName, 21) Cells(x, 7) > objFolder.GetDetailsOf(strFileName, 22) Cells(x, 8) > objFolder.GetDetailsOf(strFileName, 23) Cells(x, 9) > objFolder.GetDetailsOf(strFileName, 24) End If End If Next
Range(Selection, Selection.End(xlToRight)).Select With
Selection.Font .Name = "Verdana" .Size = 10 End With With
ActiveWindow .SplitRow = 1 .FreezePanes = True .DisplayGridlines > False End With Range(Selection, Selection.End(xlDown)).Select With
Selection .Locked = False .AutoFilter End With
Columns("A:H").AutoFit Columns("B:H").HorizontalAlignment = xlCenter
Columns("F:G").EntireColumn.Hidden = True With Application .Goto
Reference:¬tiveSheet.Range("A1"), scroll:=True
.Range(MaCellule).Select .DisplayAlerts = True .StatusBar = False
.EnableEvents = True .ScreenUpdating = True End With End Sub Function
ChoixDossierII() If Val(Application.Version) >= 10 Then With
Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName > "C:DocumentsMes Dossiers" .Show If .SelectedItems.Count > 0 Then
ChoixDossierII = .SelectedItems(1) Else ChoixDossierII = "" End If
End With Else ChoixDossierII = InputBox("Confirmer le répertoire?")
End If End Function
'--------------------------------------------------------- Merci
d'avance pour votre aide et éventuelles idées / solutions.
Cordialement,
Emile