Partager via

Visual Basic Application - Macro "Open Four Output #1 ne fonctionne plus

Anonyme
2023-01-07T17:06:55+00:00

Bonjour,

VBA - Excel 2010

Depuis le 7 mars 2004 cette macro VBA fonctionnait sans problème:

"Sub Lecture_Ecriture_Affinités_EuroMillions()

'

' Lecture_Ecriture_Fichier_EuroMillions Macro

' Macro enregistrée le 07/03/2004 par .............

'

Const A = 10000

Dim B(1 To A, 1 To 7) As Integer

Dim C As Integer, C1 As Integer, D As Integer, E As Variant, F As Integer

Dim Compteur(1 To 50, 1 To 50) As Integer

Dim intN1 As Integer, intN2 As Integer

Open "EUROMILLIONS\Euro_Millions/A_Partir_Résultats/Affinités_EuroMillions.xls" For Input As #1

For intN1 = 1 To 50

For intN2 = 1 To 50

Input #1, intN1, intN2, Compteur(intN1, intN2)

If intN2 = 50 Then GoTo suite1

Next intN2

suite1:

If intN1 = 50 Then GoTo suite2

Next intN1

suite2:

Input #1, C

Close #1

'C = C + 1

For C1 = C To A

For D = 1 To 7

Boucle_1:

E = InputBox("Saisir Nombre" & " " & D, "Tirage N°" & " " & C1 & " " & "(Pour FIN taper 0)"): F = E

If ((E > 50) Or (E < 0) Or (E = "")) Then MsgBox "Erreur de Saisie": GoTo Boucle_1

If ((E = 0) And (D = 1)) Then GoTo Fin_Saisie

B(C1, D) = F

Next D

Next C1

Fin_Saisie:

C1 = C1 - 1

For X = (C + 1) To C1

For intN1 = 1 To 50

For intN2 = 1 To 50

If B(X, 1) = intN1 And ((B(X, 1) = intN2) Or (B(X, 2) = intN2) Or (B(X, 3) = intN2) Or (B(X, 4) = intN2) Or (B(X, 5) _

= intN2)) Then Compteur(intN1, intN2) = (Compteur(intN1, intN2) + 1)

If B(X, 2) = intN1 And ((B(X, 1) = intN2) Or (B(X, 2) = intN2) Or (B(X, 3) = intN2) Or (B(X, 4) = intN2) Or (B(X, 5) _

= intN2)) Then Compteur(intN1, intN2) = (Compteur(intN1, intN2) + 1)

If B(X, 3) = intN1 And ((B(X, 1) = intN2) Or (B(X, 2) = intN2) Or (B(X, 3) = intN2) Or (B(X, 4) = intN2) Or (B(X, 5) _

= intN2)) Then Compteur(intN1, intN2) = (Compteur(intN1, intN2) + 1)

If B(X, 4) = intN1 And ((B(X, 1) = intN2) Or (B(X, 2) = intN2) Or (B(X, 3) = intN2) Or (B(X, 4) = intN2) Or (B(X, 5) _

= intN2)) Then Compteur(intN1, intN2) = (Compteur(intN1, intN2) + 1)

If B(X, 5) = intN1 And ((B(X, 1) = intN2) Or (B(X, 2) = intN2) Or (B(X, 3) = intN2) Or (B(X, 4) = intN2) Or (B(X, 5) _

= intN2)) Then Compteur(intN1, intN2) = (Compteur(intN1, intN2) + 1)

If intN2 = 50 Then GoTo suite3

Next intN2

suite3:

If intN1 = 50 Then GoTo suite4

Next intN1

suite4:

If X = C1 Then GoTo suite5

Next X

suite5:

Open "EUROMILLIONS\EURO_MILLIONS/A_Partir_Résultats/Affinités_EuroMillions.xls" For Output As #1

C = X

For intN1 = 1 To 50

For intN2 = 1 To 50

Print #1, intN1, intN2, Compteur(intN1, intN2)

Next intN2

Next intN1

Print #1, C

Close #1

End Sub "

La dernière fois qu'elle a bien fonctionné était le 30 décembre dernier.

Depuis le 3 janvier 2003 elle bloque sur :

=> Open "EUROMILLIONS\EURO_MILLIONS/A_Partir_Résultats/Affinités_EuroMillions.xls" For Output As #1

=> Sans aucun message d'erreur.

=> "Ctrl + Pause" inefficace pour l'arrêter.

=> Seule solution "Ctrl + Alt + Suppr" pour déconnexion.

Quelle(s) explication(s) ?

Quelle(s) solution(s)

Grands mercis.

Bien cordialement

Microsoft 365 et Office | Excel | Autres | Windows

Question verrouillée. Cette question a été migrée à partir de la Communauté Support Microsoft. Vous pouvez voter pour indiquer si elle est utile, mais vous ne pouvez pas ajouter de commentaires ou de réponses ni suivre la question.

0 commentaires Aucun commentaire

Réponse acceptée par l’auteur de la question

  1. Anonyme
    2023-01-18T10:05:58+00:00

    Bonjour,

    J'avais posté une réponse ce matin.

    En réponse elle a été publiée une seconde fois sans aucun autre commentaire ?

    J'ai voulu supprimer ce doublon et, en fait, les deux ont été supprimées; je réécris donc mon post de ce matin :

    "Je voulais vous informer que, depuis ce matin, ma macro fonctionne de nouveau.

    J'ai fait, via Windows Update, une recherche de mise à jour (la précédente est du 11 janvier) et effectivement il y a eu une "Mise à jour du 17 janvier 2023 pour Office 2013, Office 2010 ou Office 2007 (KB5021751)

    Je ne sais si il y a une relation de cause à effet de par nos échanges ci-dessus mais, l'ayant téléchargée et installée, j'ai relancé ma macro et....miracle...elle fonctionne.

    Merci encore.

    Cordialement"

    Cette réponse a-t-elle été utile ?

    0 commentaires Aucun commentaire

30 réponses supplémentaires

  1. Hecatonchire 53,540 Points de réputation Modérateur bénévole
    2023-01-07T19:09:38+00:00

    Bonjour,

    Le fichier Affinités_EuroMillions.xls est un fichier texte/csv avec une extension xls ?

    Cette réponse a-t-elle été utile ?

    0 commentaires Aucun commentaire
  2. DanielCo 107.7K Points de réputation
    2023-01-07T18:00:13+00:00

    Si tu isoles l'instruction dans une autre macro, est-ce que tu as le même problème ?

    Daniel

    Cette réponse a-t-elle été utile ?

    0 commentaires Aucun commentaire
  3. Anonyme
    2023-01-07T17:30:51+00:00

    Merci de votre diligence.

    Mais cette instruction est déjà positionnée en ligne 17 et j'ai déjà tenté de la renouveler tel que vous le suggérez; hélas sans succès.

    Cdlt

    Cette réponse a-t-elle été utile ?

    0 commentaires Aucun commentaire
  4. DanielCo 107.7K Points de réputation
    2023-01-07T17:17:59+00:00

    Bonjour,

    Essaie d'ajouter un :

    Close #1

    avant la ligne en erreur.

    Daniel

    Cette réponse a-t-elle été utile ?

    0 commentaires Aucun commentaire