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 :

Macro Qui Appelle Une Autre Macro


Sujet :

Macros et VBA Excel

  1. #1
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 7
    Par défaut Macro Qui Appelle Une Autre Macro
    Je voudrais créer une macro qui s'active toute seule au démarrage d'Excel et qui lance une autre macro (intitulée logs) dans le cas où j'ouvre un document intitulé log.xls dont le premier et seul onglet s'intitule log.
    Je suis débutant en VBA et je n'arrive pas à rédiger ma macro.

    Voila ce que j'ai commencé à faire... c'est pas glorieux.
    Quelqu'un pourrait m'aider à terminer mon code?

    Merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sub Auto_open()
    '
    ' Auto_Open Macro
    '
     
    If Active.Document("log.xls").Worksheets("log") Then
     
    End If
    '
    End Sub

  2. #2
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Par défaut
    Tu nommes ta macro Sub Workbook_Open() et tu la places dans Thisworkbook

  3. #3
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 7
    Par défaut
    Merci pour cette réponse.
    Mais je n'arrive pas à rédiger la première partie.
    Cette macro concerne des fichiers intitulés log.csv à 1 onglet toujours intitulé log.
    Je ne sais pas comme rédiger au début de la macro "si l'onglet du fichier ouvert s'intitule log, alors éxecuter le reste de la macro"...

  4. #4
    Membre expérimenté Avatar de ilcocodrillo
    Profil pro
    Inscrit en
    Février 2007
    Messages
    260
    Détails du profil
    Informations personnelles :
    Âge : 18
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 260
    Par défaut
    essai comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    Sub Workbook_Open()
     
    If ActiveSheet.Name = "log" Then
     
    End If
     
    End Sub

  5. #5
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 7
    Par défaut
    Non ça ne marche pas... le fichier s'ouvre tout seul mais rien ne se passe.

    Voici le texte complet de ma macro.
    J'ai mis ce texte dans la page ThisWorkbook du VBAProject (PERSO.XLS)

    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    Sub Workbook_Open()
    If ActiveSheet.Name = "log" Then
    Columns("A:A").Select
        Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
            Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
            Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
            ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
            (20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _
            Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array( _
            33, 1), Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), _
            Array(40, 1)), TrailingMinusNumbers:=True
     
        Sheets("log").Select
        Sheets.Add
        Sheets("log").Select
        Range("A1:A2674").Select
        Selection.Copy
        Sheets.Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2641").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2608").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2575").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2542").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2509").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2476").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2443").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2410").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2377").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2344").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2311").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2278").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2245").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2212").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2179").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2146").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2113").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2080").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2047").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A2014").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1981").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1948").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1915").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1882").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1849").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1816").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1783").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1750").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1717").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1684").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1651").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1618").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1585").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1552").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1519").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1486").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1453").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1420").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1387").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1354").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1321").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1288").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1255").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1222").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1189").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1156").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1123").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1090").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1057").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A1024").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A991").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A958").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A925").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A892").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A859").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A826").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A793").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A760").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A727").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A694").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A661").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A628").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A595").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A562").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A529").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A496").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A463").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A430").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A397").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A364").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A331").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A298").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A265").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A232").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A199").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A166").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A133").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A100").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A67").Select
        ActiveWindow.LargeScroll Down:=-1
        Range("A34").Select
        ActiveWindow.LargeScroll Down:=-1
        Columns("I:I").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("B:B").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=4
        Columns("M:M").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("C:C").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=4
        Columns("Q:Q").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("D:D").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=3
        Columns("U:U").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("E:E").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=5
        Columns("Y:Y").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("F:F").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=3
        Columns("AC:AC").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("G:G").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=5
        Columns("AG:AG").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("H:H").Select
        ActiveSheet.Paste
        Sheets("log").Select
        ActiveWindow.SmallScroll ToRight:=4
        Columns("AK:AK").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets.Select
        Columns("I:I").Select
        ActiveSheet.Paste
        End If
        End Sub

  6. #6
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Par défaut
    Ce que tu as fais, c'est n'importe quoi. Tu t'inspires d'un code enregistré en faisant, et tu en supprimes l'essentiel qui est l'ouverture du fichier. Là, tu n'ouvres rien !
    Jète un oeil , des fois que tu trouves ton bonheur (...)
    (pour faire du VBA, il faut commencer par les bases, et là, on ne peut franchement pas le faire à ta place.
    Bon courage et bonne chance dans tes recherches. Mais avant tout -> les bases -> Tutos -> FAQ, etc.

Discussions similaires

  1. Macro complémentaire qui appelle d'autres macros complémentaires
    Par curt dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 09/03/2015, 20h15
  2. Macro qui appelle une macro a travers la fonction Application.Calculation
    Par Mistigri5 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 02/07/2014, 01h27
  3. [XL-2003] exécution d'une macro qui appel un autre classeur sans raisons
    Par fllyann dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 28/03/2011, 10h38
  4. Macro qui ecrit une autre macro
    Par MUARIES dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 01/08/2008, 16h32
  5. servlet qui appelle une autre
    Par kam81 dans le forum Servlets/JSP
    Réponses: 7
    Dernier message: 06/11/2006, 16h14

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