IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Erreur execution '13'


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 168
    Par défaut Erreur execution '13'
    J'effectue une recherche sur un fichier excel mais je rencontre un soucis erreur execution '13' type incompatible lorque l'execution arrive sur la methode find voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
     
        Dim ObjRange As Object
        Dim ObjPrio As Object
        Dim strLUbReponse As Variant
     
        Set ObjRange = .Worksheets(lbStrQr).Range("B" & CStr(valRowAncien) & ":B" & CStr(valNbChoix) & "")
        'Set ObjRange = .ActiveSheet.Range(Cells(valRowAncien, 2), Cells(valNbChoix, 2)).Cells
       If ObjRange Is Nothing Then
                                   MsgBox "ObjRange Non instancié"
                                   Set ObjRange = Nothing
                                   Set ObjPrio = Nothing
     
                                   setReturnReponse = False
                                   Exit Function
                                'Else
                                '   ObjRange.Activate
                                End If
     
                               Set ObjPrio = ObjRange.Cells.Find(What:=CStr(strLUbReponse), _
                                                           After:=ActiveCell, _
                                                           LookIn:=xlValues, LookAt:=xlWhole, _
                                                           SearchOrder:=xlByColumns, _
                                                           SearchDirection:=xlNext, _
                                                           MatchCase:=False, SearchFormat:=False)
     
                                If ObjPrio Is Nothing Then
                                   MsgBox "ObjPrio Non instancié"
                                   Set ObjRange = Nothing
                                   Set ObjPrio = Nothing
     
                                   setReturnReponse = False
                                   Exit Function
     
                                Else
                                   ObjPrio.Activate
                                End If
                                'MsgBox
                                'Inserer la valeur réponse user D:D
                                valRowCourant = ActiveCell.Row
     
                                MsgBox valRowCourant

  2. #2
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Bonjour,

    La plupart du temps, l'erreur 13 est causé par un symbole décimal à "," au lieu du "."

    En VBA un nombre avec décimal doit être écrit 12.32 et non 12,32

    A toi de nous dire si c'est ton cas

  3. #3
    Membre Expert
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    2 130
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 2 130
    Par défaut
    Salut benoxy et le forum
    une lisibilité de #Censuré# pour un extrait de code.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Set ObjRange = .Worksheets(lbStrQr).Range("B" & CStr(valRowAncien) & ":B" & CStr(valNbChoix) & "")
    'Set ObjRange = .ActiveSheet.Range(Cells(valRowAncien, 2), Cells(valNbChoix, 2)).Cells
    If ObjRange Is Nothing Then
        MsgBox "ObjRange Non instancié"
        setReturnReponse = False
        Exit Function
    'Else
    '   ObjRange.Activate
    End If
    Set ObjPrio = ObjRange.Cells.Find(What:=CStr(strLUbReponse), _
                    After:=ActiveCell, _
                    LookIn:=xlValues, LookAt:=xlWhole, _
                    SearchOrder:=xlByColumns, _
                    SearchDirection:=xlNext, _
                    MatchCase:=False, SearchFormat:=False)
    If ObjPrio Is Nothing Then
        MsgBox "ObjPrio Non instancié"
     
        setReturnReponse = False
        Exit Function
    Else
        ObjPrio.Activate
    End If
    'MsgBox
    'Inserer la valeur réponse user D:D
    valRowCourant = ActiveCell.Row
    MsgBox valRowCourant
    Ton code sans changement, mais comme ça, il me semble plus lisible.

    Question : pourquoi un extrait ? Pourquoi pas la function en intégralité ? Le but c'est quoi ? Qu'on t'aide, ou qu'on échange des postes ?
    Regarde si le type de réponse est adapté
    A+

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 168
    Par défaut
    Salut Gorfael et jfontaine,

    voici l'intégralité de la procédure qui comme je l'ai signalé dans mon ancien message est destiné à mettre à jour un ensemble de ligne dans un fichier excel.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
     
    Public Function setReturnReponse(noQs As String, lbStrQr As String, strChronoR As String, valNbChoix As Integer, tbReponse As Variant) As Boolean
     
        Dim ObjRange As Object
        Dim ObjPrio As Object
        Dim valRowCourant As Integer
        Dim valRowAncien As Integer
        Dim strLUbReponse As Variant
        Dim cpt As Integer
        cpt = 0
        valRowCourant = 0
        valRowAncien = 0
     
        'Si il n'y a pas d'élèments on ne fait rien
        If IsArray(tbReponse) = False Then
     
            setReturnReponse = False
            Exit Function
        End If
        If UBound(tbReponse) <> 0 Then
        'xlBook.Worksheets(2).Cells(1, 1).Select
        'MsgBox lbStrQr
        If xlBook Is Nothing Then
            lbQr = lbStrQr
            'Set xlBook = xlApp.Workbooks("c:\temp\tempqcmxls.xls")
            Call setOpenSession
            MsgBox "Instancié"
        End If
        'MsgBox "Numéro de Question :" & noQs
        With xlBook
                '.Worksheets(lbStrQr).Activate
                .ActiveSheet.Cells(1, 1).Select
                'Recherche no question A:A
                With .Worksheets(lbStrQr).Columns("A:A")
                                  .Find(What:="" & noQs & "", _
                                              LookIn:=xlValues, LookAt:=xlWhole, _
                                              SearchOrder:=xlByColumns, _
                                              SearchDirection:=xlNext, _
                                              MatchCase:=False, SearchFormat:=False).Activate
     
                End With
                'Inserer la valeur du chronométre E:E
                valRowCourant = ActiveCell.Row
                valRowAncien = valRowCourant
                '.Worksheets(lbStrQr).Cells(valRowCourant, 5).Value = strChronoR
                '.Worksheets(2).Cells(valRowAncien, 2).Select
                'MsgBox "Chrono fait:" & UBound(tbReponse)
                'Calcule pour definir la plage de recherche
                valNbChoix = valNbChoix + valRowAncien
                'Recherche lbreponse B:B
                For cpt = 0 To UBound(tbReponse)
                    .Worksheets(lbStrQr).Cells(valRowAncien, 2).Activate
                    If tbReponse(cpt) <> "" Then
                        strLUbReponse = Mid(tbReponse(cpt), 1, _
                                            InStr(1, tbReponse(cpt), "|") - 1)
                        'Si rien n'a été sélectionné =R
                        'on ne rentre
                         If strLUbReponse <> "R" Then
     
     
                               Set ObjRange = .Worksheets(lbStrQr).Range("B" & CStr(valRowAncien) & ":B" & CStr(valNbChoix) & "")
                               'Set ObjRange = .ActiveSheet.Range(Cells(valRowAncien, 2), Cells(valNbChoix, 2)).Cells
                                If ObjRange Is Nothing Then
                                   MsgBox "ObjRange Non instancié"
                                   Set ObjRange = Nothing
                                   Set ObjPrio = Nothing
     
                                   setReturnReponse = False
                                   Exit Function
                                'Else
                                '   ObjRange.Activate
                                End If
     
                               Set ObjPrio = ObjRange.Cells.Find(What:=CStr(strLUbReponse), _
                                         After:=ActiveCell, _
                                         LookIn:=xlValues, LookAt:=xlWhole, _
                                         SearchOrder:=xlByColumns, _
                                         SearchDirection:=xlNext, _
                                         MatchCase:=False, SearchFormat:=False)
     
                                If ObjPrio Is Nothing Then
                                   MsgBox "ObjPrio Non instancié"
                                   Set ObjRange = Nothing
                                   Set ObjPrio = Nothing
     
                                   setReturnReponse = False
                                   Exit Function
     
                                Else
                                   ObjPrio.Activate
                                End If
                                'MsgBox
                                'Inserer la valeur réponse user D:D
                                valRowCourant = ActiveCell.Row
     
                                MsgBox valRowCourant
                                'Si le contenue du tableau (OUI) = Contenu de la cell (OUI)
                                ' inscrire valeur
                                   If Trim(strLUbReponse) = Trim(CStr(.Worksheets(2).Cells(valRowCourant, 2).Value)) Then
                                    'MsgBox Mid(tbReponse(cpt), InStr(1, tbReponse(cpt), "|") + 1, 1) & ":valCell>" & CStr(.Worksheets(2).Cells(valRowCourant, 2).Value)
                                    .Worksheets(lbStrQr).Cells(valRowCourant, 4).Value = Mid(tbReponse(cpt), _
                                                                                      InStr(1, tbReponse(cpt), "|") + 1, _
                                                                                      1)
                                    'MsgBox "reponseU>" & strLUbReponse & ":valCell>" & CStr(.Worksheets(2).Cells(valRowCourant, 2).Value)
     
                                    'MsgBox tbReponse(cpt) & "-tbReponse/" & valRowAncien & "-RA / " & valRowCourant & "-RC/ valCell = " & CStr(.Worksheets(2).Cells(valRowCourant, 4).Value)
                                End If
                        End If
                    End If
     
                Next
                .Save
        End With
        End If
        'If Err.Number <> 0 And Err.Number <> 91 Then
     '       MsgBox Err.Number
       '     GoTo ERR_OnSetReturnReponse
        'End If
        Set ObjRange = Nothing
        Set ObjPrio = Nothing
        'MsgBox "Fin True"
        setReturnReponse = True
    'ERR_OnSetReturnReponse:
     '   MsgBox "Fin False"
     '   setReturnReponse = False
    End Function

    L'erreur d'exécution se produit à cette ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Set ObjPrio = ObjRange.Cells.Find(What:=CStr(strLUbReponse), _
                       After:=ActiveCell, _
                       LookIn:=xlValues, LookAt:=xlWhole, _
                       SearchOrder:=xlByColumns, _
                       SearchDirection:=xlNext, _
                       MatchCase:=False, SearchFormat:=False)

  5. #5
    Membre Expert
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    2 130
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 2 130
    Par défaut
    Salut benoxy et le forum
    Je n'ai pas réellement cherché, mais essaie cette fonction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Function aa(B As Range) As Boolean
    Application.volatile
    [A5].Activate
    aa = True
    End Function
    Tu mets un point d'arrêt sur le titre et tu la mets en B15 par exemple.
    Tu fais du Pas-à-pas avec F8 et tu regardes une des limitations des Function
    A+

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 168
    Par défaut
    Salut,

    Une précision, j'effectue la mise à jour du fichier Excel à partir d'une présentation PowerPoint 2003. J'utilise donc le VBA de PowerPoint 2003.

  7. #7
    Invité
    Invité(e)
    Par défaut
    Bonjour

    Citation Envoyé par benoxy Voir le message
    Salut,

    Une précision, j'effectue la mise à jour du fichier Excel à partir d'une présentation PowerPoint 2003. J'utilise donc le VBA de PowerPoint 2003.
    Attention (car c'est moi qui est déplacé la discussion ici), bien que tu sois dans PowerPoint, tu utilises le VBA Excel dans ton cas pour récupérer des informations dans Excel, et non le VBA PowerPoint qui lui ne sert qu'à programmer ta présentation, tes diapositives, etc ....


    Philippe

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VB6-MSADO 2.5 - Oracle 9.2] Erreur Execution 80004005
    Par GyLes dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 27/02/2006, 18h10
  2. [VBA] Aide Erreur execution !!
    Par Virgile59 dans le forum VBA Access
    Réponses: 2
    Dernier message: 10/02/2006, 12h01
  3. [PHP MySQL] Erreur execution requête de type INSERT
    Par Pfeffer dans le forum Requêtes
    Réponses: 6
    Dernier message: 23/01/2006, 17h38
  4. Réponses: 18
    Dernier message: 10/12/2005, 01h19
  5. [Ant]Erreur execution d'une tache ANT
    Par gerin dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 11/05/2004, 16h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo