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

VBA Word Discussion :

Macro qui ne fonctionne plus depuis changement OS [WD-2003]


Sujet :

VBA Word

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Macro qui ne fonctionne plus depuis changement OS
    Bonjour à tous,

    Dans le cadre du boulot j'avais "bricolé" (le mot est bien choisi puisque je n'y connais pas grand chose) une macro pour mettre en forme des centaines de pages word.

    Suite au changement d'OS sur l'ensemble du parc (XP vers W7) la macro ne fonctionne plus. La version d'office est pourtant la même : 2003

    Erreur de compilation :
    Sub ou Fonction non définie


    Ce qui m'intéresse dans cette macro est de pouvoir supprimer toutes les lignes contenant un terme suivi d'un retour chariot. Histoire de supprimer toutes les lignes vides en fait.

    Voici une copie de la macro : Elle bloque systématiquement sur la
    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
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    fonction "Supp"
    
    ' Macro
    Guide Macro
    
    ' Macro créée le 22/10/2012 par ***
    
    'Remplacement Dates retour chariot tiret deux points 13 espaces par Dates '
    
        Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
     Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "-^p"
    
            .Replacement.Text = "^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
        'Remplacement Date tiret et retour chariot'
    
        Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
          'Remplacement retour chariot 13 espaces par Dates Italique'
    
        Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
    Selection.HomeKey unit:=wdStory
    
    supp "^p^p^p^p"
    
    supp "Caractéristiques et contraintes : ^p"
    
    supp "Mode de classement : ^p"
    
    supp "Introduction : ^p"
    
    supp "Bibliographie : ^p"
    
    supp "Sources complémentaires : ^p"
    
    supp "Editeur : ^p"
    
    supp "Dates : ^p"
    
    supp "Dates : - ^p"
    
    supp "Date libre :  ^p"
    
    supp "Date édition : ^p"
    
    supp "Importance matérielle et support : ^p"
    
    supp "Nom du producteur ou Auteur : ^p"
    
    supp "Biographie : ^p"
    
    supp "Historique de la conservation : ^p"
    
    supp "Modalité d'entrée : ^p"
    
    supp "Niveau de description : ^p"
    
    supp "Présentation du contenu : ^p"
    
    supp "Modalité de reproduction : ^p"
    
    supp "Evaluation : ^p"
    
    supp "Conditions d'accès : ^p"
    
    supp "Instrument de recherche : ^p"
    
    supp "Lieu de conservation : ^p"
    
    supp "Bibliographie : ^p"
    
    supp "Notes : ^p"
    
    supp "Technique : ^p"
    
    supp "Format : ^p"
    
    supp "Introduction :^p"
    
    supp "Auteur : ^p"
    
    supp "Auteurs : ^p"
    
    supp "Titre : ^p"
    
    supp "Importance matérielle et support : . ."
    
    supp "^p^p^p^p"
    
    supp "^p^p^p"
    
    Selection.HomeKey unit:=wdStory
    
    With Selection.Find
    
        .ClearFormatting
    
        .Replacement.ClearFormatting
    
        .Forward = True
    
        .MatchWildcards = False
    
        .Text = Chr(11)
    
        .Replacement.Text = vbCr
    
        .Execute Replace:=wdReplaceAll
    
    End With
    
    Selection.HomeKey unit:=wdStory
    
     
    
     
    
    With Selection.Find
    
        .Replacement.Text = ""
    
        .Text = txt
    
        .Execute
    
    End With
    
    While Selection.Find.Found
    
        Selection.MoveRight
    
        Selection.MoveUp unit:=wdParagraph, Count:=1, Extend:=wdMove
    
        Selection.MoveDown unit:=wdParagraph, Count:=1, Extend:=True
    
        Selection.Delete
    
        Selection.Find.Execute
    
    Wend
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "              ^p"
    
            .Replacement.Text = ""
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
    'Remplacement quatre retours chariot Macro'
    
     
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "^p^p^p^p"
    
            .Replacement.Text = "^p^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
    'Remplacement tiret suivi de retour chariot'
    
     
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "-^p"
    
            .Replacement.Text = "^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
     
    
     
    
    End Sub
    
     
    
    Sub ESSAI()
    
     Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
     Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "-^p"
    
            .Replacement.Text = "^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
        'Remplacement Date tiret et retour chariot'
    
        Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
          'Remplacement retour chariot 13 espaces par Dates Italique'
    
        Selection.Find.ClearFormatting
    
          Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "Dates : -^p             "
    
            .Replacement.Text = "Dates : "
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        
    
    Selection.HomeKey unit:=wdStory
    
    With Selection.Find
    
        .ClearFormatting
    
        .Replacement.ClearFormatting
    
        .Forward = True
    
        .MatchWildcards = False
    
        .Text = Chr(11)
    
        .Replacement.Text = vbCr
    
        .Execute Replace:=wdReplaceAll
    
    End With
    
    Selection.HomeKey unit:=wdStory
    
     
    
     
    
    With Selection.Find
    
        .Replacement.Text = ""
    
        .Text = txt
    
        .Execute
    
    End With
    
    While Selection.Find.Found
    
        Selection.MoveRight
    
        Selection.MoveUp unit:=wdParagraph, Count:=1, Extend:=wdMove
    
        Selection.MoveDown unit:=wdParagraph, Count:=1, Extend:=True
    
        Selection.Delete
    
        Selection.Find.Execute
    
    Wend
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "              ^p"
    
            .Replacement.Text = ""
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
    'Remplacement quatre retours chariot Macro'
    
     
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "^p^p^p^p"
    
            .Replacement.Text = "^p^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
    'Remplacement tiret suivi de retour chariot'
    
     
    
        Selection.Find.ClearFormatting
    
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
    
            .Text = "-^p"
    
            .Replacement.Text = "^p"
    
            .Forward = True
    
            .Wrap = wdFindContinue
    
            .Format = False
    
            .MatchCase = False
    
            .MatchWholeWord = False
    
            .MatchWildcards = False
    
            .MatchSoundsLike = False
    
            .MatchAllWordForms = False
    
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
     
    End Sub

    Si vous aviez un élément de réponse, ça m'aiderait vraiment.

    Merci par avance

    Stéphane

  2. #2
    Membre expert

    Homme Profil pro
    Spécialiste progiciel
    Inscrit en
    Février 2010
    Messages
    1 747
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Spécialiste progiciel
    Secteur : Service public

    Informations forums :
    Inscription : Février 2010
    Messages : 1 747
    Points : 3 016
    Points
    3 016
    Par défaut
    Bonjour,
    le problème est que la fonction ou procédure supp n'est pas définie.
    Elle devait peut-être se trouver dans ton modèle normal mais n'a pas été recopiée.
    Il te faudrait alors recréer ou réinmporter cette procédure
    Cordialement,
    Christophe

    Merci de ne pas oublier de mettre résolu quand le sujet l'est. Cela aide tous les DVPnautes dans leur recherche

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Merci beaucoup

    - Création d'une nouvelle macro à partir d'un modèle Word
    - Reprise des élèments de la macro actuelle en procédant pas à pas

    Ca fonctionne !

    Merci encore

    Bonne journée

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

Discussions similaires

  1. Macro qui ne fonctionne plus sur 2010
    Par Charlie3 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 26/01/2013, 16h29
  2. [XL-2007] Problème de macro qui ne marche plus depuis migration sur 2007
    Par tunimaal dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 05/01/2013, 09h51
  3. [XL-2003] Problème avec 2 macros qui fonctionnaient mais qui ne fonctionnent plus
    Par amilka dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 22/03/2010, 08h25
  4. Macro qui ne marche plus depuis un userform
    Par Ramoneur dans le forum Macros et VBA Excel
    Réponses: 39
    Dernier message: 19/06/2008, 15h37
  5. Réponses: 0
    Dernier message: 02/08/2007, 14h20

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