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 muette suite à passage Office 2010 -> Office 2016


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Conseil en assistance à maîtrise d'ouvrage
    Inscrit en
    Septembre 2014
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Conseil en assistance à maîtrise d'ouvrage
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2014
    Messages : 33
    Par défaut Macro muette suite à passage Office 2010 -> Office 2016
    Bonjour à tout le monde.

    Dans le cadre de mon taff, je réalise, grâce à un fichier Excel, le rapport mensuel de maintenance de l'ensemble des services de mon client.
    Ce dernier contient une quarantaine d'onglets contenant des tables liées à Access (lien vers des bases de données issues de nos solutions de GMAO) ou des tableaux croisés dynamiques.

    Une fois l'ensemble des données mises à jour, je lance la macro "GénérerLesRapports", qui créé, pour chaque service, un fichier Word, à partir d'un fichier Word "modèle". Pour ce faire, la macro copie les données des différent(e)s tableaux / tables et les colle vers les signets du document original. Enfin, elle sauvegarde le fichier dûment rempli sous la forme "Rapport mensuel - Mois Année - Service xxxx".

    Or, depuis ce week-end, notre suite Office a été upgradée de la version 2010 à la version 2016.
    Et, depuis, ma macro fonctionne mais ne remplit plus mon fichier Word. J'ai bien les fichiers de chaque service qui sont créés, mais ils sont vides des données issues d'Excel.

    Je recherche éventuellement des appels à des librairies, qui auraient changé entre les deux versions d'Office, mais j'avoue que je ne maîtrise pas du tout le sujet. Le fichier Excel a été mis en place par un collègue (qui a quitté la société depuis), qui n'est pas développeur, mais dont les compétences surpassent de loin les miennes. J'ai déjà regardé dans "Outils / Références" mais n'ai rien trouvé de bizarre (pas de librairie "manquante") et je ne sais pas quoi regardé d'autres.

    Ci-dessous le code que j'utilise (désolé pour le pavé !!!) :

    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
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    Sub GénérerLesRapports()
     
    Dim DernLigne As Long
    Dim truc As DataObject
    Dim MEMTXT As String
    Dim ISITXT As String
    Dim CITXT As String
    Dim STLTXT As String
    Dim NBLIGNEBT As Long
    Dim NbIGS As Long
    Dim i As Integer
    Dim Pvt As PivotTable
    Dim appWrd As Word.Application
    Dim docWord As Word.Document
    Dim PvtItm As String
    Dim ThisYear As Long
    Set appWrd = CreateObject("Word.Application")
    appWrd.Visible = False
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------   MISE A JOUR DES TABLEAUX CROISES   ------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique12").PivotCache.Refresh       'STL
    Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique13").PivotCache.Refresh       'Chef d'installation
    Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique14").PivotCache.Refresh       'ISI
    Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique15").PivotCache.Refresh       'MEM
    Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique16").PivotCache.Refresh     'Inventaire facturé
    Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique17").PivotCache.Refresh     'Inventaire en cours
    Sheets("Rapport - BT RE").PivotTables("Tableau croisé dynamique2").PivotCache.Refresh           'BT RE
    Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique3").PivotCache.Refresh           'Devis
    Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique4").PivotCache.Refresh           'Devis
    Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotCache.Refresh           'Devis
    Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique9").PivotCache.Refresh             'PDR
    Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotCache.Refresh            'PDR
    Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique11").PivotCache.Refresh            'PDR
    Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique6").PivotCache.Refresh              'FP
    Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique8").PivotCache.Refresh              'FP
     
    AUJ = InputBox("Jour de la création des rapports ?                    (Format JJ/MM/AAAA)", "Date", "XXX")
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------------   FILTRE IGS   -----------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    NbIGS = Sheets("Liste IGS").Range("B1048576").End(xlUp).Row
     
    For h = 2 To 3 ' NbIGS
    'For Each h In Array(19, 27, 51, 57, 74)
    'For Each h In Array(85, 86)
     
    If Sheets("Liste IGS").Range("I" & h).Value = 0 Then
     
    '    h = h + 1
     
    Else
     
        On Error Resume Next
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique12").PivotFields("IGS").ClearAllFilters                                             'STL
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique12").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique13").PivotFields("IGS").ClearAllFilters                                             'Chef d'installation
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique13").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique14").PivotFields("IGS").ClearAllFilters                                             'ISI
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique14").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique15").PivotFields("IGS").ClearAllFilters                                             'MEM
        Sheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique15").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique16").PivotFields("IGS").ClearAllFilters                                           'Inventaire facturé
        Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique16").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique17").PivotFields("IGS").ClearAllFilters                                           'Inventaire en cours
        Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique17").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - BT RE").PivotTables("Tableau croisé dynamique2").PivotFields("IGS").ClearAllFilters                                                 'BT RE
        Sheets("Rapport - BT RE").PivotTables("Tableau croisé dynamique2").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique3").PivotFields("IGS").ClearAllFilters                                                 'Devis
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique3").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique4").PivotFields("IGS").ClearAllFilters                                                 'Devis
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique4").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("IGS").ClearAllFilters                                                 'Devis
        Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique9").PivotFields("IGS").ClearAllFilters                                                   'PDR
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique9").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("IGS").ClearAllFilters                                                  'PDR
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique11").PivotFields("IGS").ClearAllFilters                                                  'PDR
        Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique11").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - PRM").PivotTables("Tableau croisé dynamique7").PivotFields("IGS").ClearAllFilters                                                   'PRM
        Sheets("Rapport - PRM").PivotTables("Tableau croisé dynamique7").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique6").PivotFields("IGS").ClearAllFilters                                                    'FP
        Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique6").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique8").PivotFields("IGS").ClearAllFilters                                                    'FP
        Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique8").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - BT RAD POR").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                            'BT POR RAD
        Sheets("Rapport - BT RAD POR").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - BT RE RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                             'BT RE RAD
        Sheets("Rapport - BT RE RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - INV RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                               'INV RAD
        Sheets("Rapport - INV RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - BT ATPLA RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                          'INV RAD
        Sheets("Rapport - BT ATPLA RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - INV TEA").PivotTables("Tableau croisé dynamique2").PivotFields("IGS").ClearAllFilters                                               'INV TEA
        Sheets("Rapport - INV TEA").PivotTables("Tableau croisé dynamique2").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - TEA BT").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                                'INV TEA
        Sheets("Rapport - TEA BT").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - MEMPVI").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                                'INV TEA
        Sheets("Rapport - MEMPVI").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - BT CP").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                                 'BT CP
        Sheets("Rapport - BT CP").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - PRM EER").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                               'PRM EER
        Sheets("Rapport - PRM EER").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
        Sheets("Rapport - EES PRM").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").ClearAllFilters                                               'PRM EES
        Sheets("Rapport - EES PRM").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = Sheets("Liste IGS").Range("B" & h).Value
     
        Set docWord = appWrd.Documents. _
        Open("\\lurs\_partage\Maint\CIM\MEM\07 - Suivi  - Amélioration continue\03 - Reporting\Rapport aux installations\Rapport.docx", ReadOnly:=True)
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '----------------------------------------------------------------------------------------------   NUMERO IGS + MOIS DU RAPPORT   -------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
        docWord.Bookmarks("IGS").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("Mois").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete1").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete2").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete3").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete4").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete5").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete6").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete7").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        docWord.Bookmarks("Entete8").Range.Text = Right(Sheets("Accueil").Range("P10").Value, 7)
        'docWord.Tables(1).AutoFitBehavior wdAutoFitWindow
        docWord.Bookmarks("IGS1").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS2").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS3").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS4").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS5").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS6").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS7").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
        docWord.Bookmarks("IGS8").Range.Text = Sheets("Liste IGS").Range("B" & h).Value
     
        docWord.Bookmarks("Date1").Range.Text = AUJ
        docWord.Bookmarks("Date2").Range.Text = AUJ
        docWord.Bookmarks("Date3").Range.Text = AUJ
        docWord.Bookmarks("Date4").Range.Text = AUJ
        docWord.Bookmarks("Date5").Range.Text = AUJ
        docWord.Bookmarks("Date6").Range.Text = AUJ
        docWord.Bookmarks("Date7").Range.Text = AUJ
        docWord.Bookmarks("Date8").Range.Text = AUJ
     
        docWord.Bookmarks("FileName1").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName2").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName3").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName4").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName5").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName6").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName7").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
        docWord.Bookmarks("FileName8").Range.Text = Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018.pdf"
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------------------------------------------------------------------------------------------------   CONTACTS   -----------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Set Pvt = Worksheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique13")
    NBCI = Pvt.TableRange2.Rows.Count
     
    If NBCI = 5 Then
     
        docWord.Bookmarks("CI").Range.Text = Sheets("Rapport - Contacts").Range("B6").Value
     
    Else
     
        If NBCI = 4 Then
     
            docWord.Bookmarks("CI").Range.Text = "Aucun"
     
        Else
     
            If NBCI > 5 Then
     
                NBCI = NBCI + 1
                For S = 6 To NBCI
     
                If S = NBMEM Then
     
                    CITXT = CITXT & Sheets("Rapport - Contacts").Range("B" & S).Value
     
                Else
     
                    CITXT = CITXT & Sheets("Rapport - Contacts").Range("B" & S).Value & " - "
     
                End If
     
                Next
                docWord.Bookmarks("CI").Range.Text = CITXT
     
            End If
     
        End If
     
    End If
     
    Set Pvt = Worksheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique14")
    NBISI = Pvt.TableRange2.Rows.Count
     
    If NBISI = 5 Then
     
        docWord.Bookmarks("ISI").Range.Text = Sheets("Rapport - Contacts").Range("F6").Value
     
    Else
     
        If NBISI = 4 Then
     
            docWord.Bookmarks("ISI").Range.Text = "Aucun"
     
        Else
     
            If NBISI > 5 Then
     
                NBISI = NBISI + 1
                For v = 6 To NBISI
     
                If v = NBMEM Then
     
                    ISITXT = ISITXT & Sheets("Rapport - Contacts").Range("F" & v).Value
     
                Else
     
                    ISITXT = ISITXT & Sheets("Rapport - Contacts").Range("F" & v).Value & " - "
     
                End If
     
                Next
                docWord.Bookmarks("ISI").Range.Text = ISITXT
     
            End If
     
        End If
     
    End If
     
    MEMTXT = ""
    Set Pvt = Worksheets("Rapport - Contacts").PivotTables("Tableau croisé dynamique15")
    NBMEM = Pvt.TableRange2.Rows.Count
     
    If NBMEM = 5 Then
     
        docWord.Bookmarks("MEM").Range.Text = Sheets("Rapport - Contacts").Range("J6").Value
     
    Else
     
        If NBMEM = 4 Then
     
            docWord.Bookmarks("MEM").Range.Text = "Aucun"
     
        Else
     
            If NBMEM > 5 Then
     
                NBMEM = NBMEM + 1
                Dim y As Integer
                For y = 6 To NBMEM
     
                If y = NBMEM Then
     
                    MEMTXT = MEMTXT & Sheets("Rapport - Contacts").Range("J" & y).Value
     
                Else
     
                    MEMTXT = MEMTXT & Sheets("Rapport - Contacts").Range("J" & y).Value & " - "
     
                End If
     
                Next
     
            End If
     
            docWord.Bookmarks("MEM").Range.Text = MEMTXT
     
        End If
     
    End If
     
    docWord.Bookmarks("STL").Range.Text = Sheets("Rapport - Contacts").Range("N6").Value
    docWord.Bookmarks("TEA").Range.Text = "M. VINOT Thomas"
    docWord.Bookmarks("RAD").Range.Text = "Mme GARREL Agnès"
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '----------------------------------------------------------------------------------------------------   BT CP MEM   --------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - BT CP").PivotTables("Tableau croisé dynamique1").PivotFields("IGS").CurrentPage = "(All)" Then
     
        docWord.Bookmarks("MEMCPATAPP").Range.Text = Sheets("Rapport - BT CP").Range("P5").Value
        docWord.Bookmarks("MEMCPATAVT").Range.Text = Sheets("Rapport - BT CP").Range("P6").Value
        docWord.Bookmarks("MEMCPVALAVT").Range.Text = Sheets("Rapport - BT CP").Range("P7").Value
        docWord.Bookmarks("MEMCPZTAVT").Range.Text = Sheets("Rapport - BT CP").Range("P8").Value
        docWord.Bookmarks("MEMCPENCRS").Range.Text = Sheets("Rapport - BT CP").Range("P9").Value
        docWord.Bookmarks("MEMCPZTAPT").Range.Text = Sheets("Rapport - BT CP").Range("P10").Value
        docWord.Bookmarks("MEMCPATVAPT").Range.Text = Sheets("Rapport - BT CP").Range("P11").Value
        docWord.Bookmarks("MEMCPVALAPT").Range.Text = Sheets("Rapport - BT CP").Range("P12").Value
        docWord.Bookmarks("MEMCPTERMI").Range.Text = Sheets("Rapport - BT CP").Range("P13").Value
        docWord.Bookmarks("MEMCPFERMER").Range.Text = Sheets("Rapport - BT CP").Range("P14").Value
        docWord.Bookmarks("MEMCPANN").Range.Text = Sheets("Rapport - BT CP").Range("P16").Value
        docWord.Bookmarks("MEMCPREFAVT").Range.Text = Sheets("Rapport - BT CP").Range("P17").Value
        docWord.Bookmarks("MEMCPREFAPT").Range.Text = Sheets("Rapport - BT CP").Range("P18").Value
        docWord.Bookmarks("MEMCPEISATAPP").Range.Text = Sheets("Rapport - BT CP").Range("Q5").Value
        docWord.Bookmarks("MEMCPEISATAVT").Range.Text = Sheets("Rapport - BT CP").Range("Q6").Value
        docWord.Bookmarks("MEMCPEISVALAVT").Range.Text = Sheets("Rapport - BT CP").Range("Q7").Value
        docWord.Bookmarks("MEMCPEISZTAVT").Range.Text = Sheets("Rapport - BT CP").Range("Q8").Value
        docWord.Bookmarks("MEMCPEISENCRS").Range.Text = Sheets("Rapport - BT CP").Range("Q9").Value
        docWord.Bookmarks("MEMCPEISZTAPT").Range.Text = Sheets("Rapport - BT CP").Range("Q10").Value
        docWord.Bookmarks("MEMCPEISATVAPT").Range.Text = Sheets("Rapport - BT CP").Range("Q11").Value
        docWord.Bookmarks("MEMCPEISVALAPT").Range.Text = Sheets("Rapport - BT CP").Range("Q12").Value
        docWord.Bookmarks("MEMCPEISTERMI").Range.Text = Sheets("Rapport - BT CP").Range("Q13").Value
        docWord.Bookmarks("MEMCPEISFERMER").Range.Text = Sheets("Rapport - BT CP").Range("Q14").Value
        docWord.Bookmarks("MEMCPEISANN").Range.Text = Sheets("Rapport - BT CP").Range("Q16").Value
        docWord.Bookmarks("MEMCPEISREFAVT").Range.Text = Sheets("Rapport - BT CP").Range("Q17").Value
        docWord.Bookmarks("MEMCPEISREFAPT").Range.Text = Sheets("Rapport - BT CP").Range("Q18").Value
     
    Else
     
        docWord.Bookmarks("MEMCPEISATAPP").Range.Text = Sheets("Rapport - BT CP").Range("L5").Value
        docWord.Bookmarks("MEMCPEISATAVT").Range.Text = Sheets("Rapport - BT CP").Range("L6").Value
        docWord.Bookmarks("MEMCPEISVALAVT").Range.Text = Sheets("Rapport - BT CP").Range("L7").Value
        docWord.Bookmarks("MEMCPEISZTAVT").Range.Text = Sheets("Rapport - BT CP").Range("L8").Value
        docWord.Bookmarks("MEMCPEISENCRS").Range.Text = Sheets("Rapport - BT CP").Range("L9").Value
        docWord.Bookmarks("MEMCPEISZTAPT").Range.Text = Sheets("Rapport - BT CP").Range("L10").Value
        docWord.Bookmarks("MEMCPEISATVAPT").Range.Text = Sheets("Rapport - BT CP").Range("L11").Value
        docWord.Bookmarks("MEMCPEISVALAPT").Range.Text = Sheets("Rapport - BT CP").Range("L12").Value
        docWord.Bookmarks("MEMCPEISTERMI").Range.Text = Sheets("Rapport - BT CP").Range("L13").Value
        docWord.Bookmarks("MEMCPEISFERMER").Range.Text = Sheets("Rapport - BT CP").Range("L14").Value
        docWord.Bookmarks("MEMCPEISANN").Range.Text = Sheets("Rapport - BT CP").Range("L16").Value
        docWord.Bookmarks("MEMCPEISREFAVT").Range.Text = Sheets("Rapport - BT CP").Range("L17").Value
        docWord.Bookmarks("MEMCPEISREFAPT").Range.Text = Sheets("Rapport - BT CP").Range("L18").Value
        docWord.Bookmarks("MEMCPATAPP").Range.Text = Sheets("Rapport - BT CP").Range("M5").Value
        docWord.Bookmarks("MEMCPATAVT").Range.Text = Sheets("Rapport - BT CP").Range("M6").Value
        docWord.Bookmarks("MEMCPVALAVT").Range.Text = Sheets("Rapport - BT CP").Range("M7").Value
        docWord.Bookmarks("MEMCPZTAVT").Range.Text = Sheets("Rapport - BT CP").Range("M8").Value
        docWord.Bookmarks("MEMCPENCRS").Range.Text = Sheets("Rapport - BT CP").Range("M9").Value
        docWord.Bookmarks("MEMCPZTAPT").Range.Text = Sheets("Rapport - BT CP").Range("M10").Value
        docWord.Bookmarks("MEMCPATVAPT").Range.Text = Sheets("Rapport - BT CP").Range("M11").Value
        docWord.Bookmarks("MEMCPVALAPT").Range.Text = Sheets("Rapport - BT CP").Range("M12").Value
        docWord.Bookmarks("MEMCPTERMI").Range.Text = Sheets("Rapport - BT CP").Range("M13").Value
        docWord.Bookmarks("MEMCPFERMER").Range.Text = Sheets("Rapport - BT CP").Range("M14").Value
        docWord.Bookmarks("MEMCPANN").Range.Text = Sheets("Rapport - BT CP").Range("M16").Value
        docWord.Bookmarks("MEMCPREFAVT").Range.Text = Sheets("Rapport - BT CP").Range("M17").Value
        docWord.Bookmarks("MEMCPREFAPT").Range.Text = Sheets("Rapport - BT CP").Range("M18").Value
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------------   BT RE   ---------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Set Pvt = Worksheets("Rapport - BT RE").PivotTables("Tableau croisé dynamique2")
    A = Pvt.TableRange2.Rows.Count
    A = A + 2
     
    If Sheets("Rapport - BT RE").PivotTables("Tableau croisé dynamique2").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("BTREgraph").Range.Text = "Aucun BT RE sur l'année du rapport."
     
    Else
     
        If Sheets("Rapport - BT RE 2").Range("O81") = "" Then
     
            docWord.Bookmarks("BTREgraph").Range.Text = "Aucun BT RE sur l'année du rapport."
     
        Else
     
            Sheets("Rapport - BT RE 2").Range("$B$2:$O$81").AutoFilter Field:=14, Criteria1:="<>"
            Sheets("Rapport - BT RE 2").Range("A3:P81").Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="BTREgraph"                                                     'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------------------------------------------------------------------------------------------   FICHES PROGRES   -----------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Set Pvt = Worksheets("Rapport - FP").PivotTables("Tableau croisé dynamique6")
    b = Pvt.TableRange2.Rows.Count
     
    If Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique6").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("FP").Range.Text = "Aucune FP transmise en attente de retour."
     
    ElseIf b = 5 Then 'b = 6
     
        docWord.Bookmarks("FP").Range.Text = "Aucune FP transmise en attente de retour."
     
    Else
     
        Sheets("Rapport - FP").Range("A5:C" & b).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="FP"                                                                'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------------   DEVIS   ----------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique3").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("Devis").Range.Text = "Aucun devis transmis et non facturé."
     
    Else
     
        Set Pvt = Worksheets("Rapport - Devis").PivotTables("Tableau croisé dynamique3")
        c = Pvt.TableRange2.Rows.Count
     
        If c = 7 Then
     
            appWrd.Activate
            docWord.Bookmarks("Devis").Range.Text = "Aucun devis transmis et non facturé."
     
        Else
     
            c = c + 1
            Sheets("Rapport - Devis").Range("A7:D" & c).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="Devis"                                                         'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    ' ESSAI N°3 DE PIVOT ITEMS
    'ThisYear = Right(Worksheets("Accueil").Range("N10").Value, 4)
    '
    'With Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("Mois Fact")
    '
    '    For AnneeRapport = 2014 To ThisYear
    '
    '        For MoisRapport = 1 To 12
    '
    '            PvtItm = "" & AnneeRapport & "/" & MoisRapport & ""
    '
    '            If AnneeRapport = Year(Range(Sheets("Accueil").Cells("P10"))) Then
    '
    '                If MoisRapport = Month(Range(Sheets("Accueil").Cells("P10"))) Then
    '
    '                        .PivotItems(PvtItm).Visible = True
    '
    '                Else: .PivotItems(PvtItm).Visible = False
    '
    '                End If
    '
    '            End If
    '
    '        Next
    '
    '    Next
    '
    'End With
     
    ' ESSAI N°2 DE PIVOT ITEMS
    'PvtItms = "" & Worksheets("Accueil").Range("N10").Value & ""
    '
    'With Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("Mois Fact")
    '
    '.PivotItems(PvtItms).Visible = True
    '
    'End With
     
     
    ' ESSAI N°1 DE PIVOT ITEMS
    With Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("Mois Fact")
     
        .PivotItems("/").Visible = False
        .PivotItems("2014/01").Visible = False
        .PivotItems("2014/02").Visible = False
        .PivotItems("2014/03").Visible = False
        .PivotItems("2014/04").Visible = False
        .PivotItems("2014/05").Visible = False
        .PivotItems("2014/06").Visible = False
        .PivotItems("2014/07").Visible = False
        .PivotItems("2014/08").Visible = False
        .PivotItems("2014/09").Visible = False
        .PivotItems("2014/10").Visible = False
        .PivotItems("2014/11").Visible = False
        .PivotItems("2014/12").Visible = False
        .PivotItems("2015/01").Visible = False
        .PivotItems("2015/02").Visible = False
        .PivotItems("2015/03").Visible = False
        .PivotItems("2015/04").Visible = False
        .PivotItems("2015/05").Visible = False
        .PivotItems("2015/06").Visible = False
        .PivotItems("2015/07").Visible = False
        .PivotItems("2015/08").Visible = False
        .PivotItems("2015/09").Visible = False
        .PivotItems("2015/10").Visible = False
        .PivotItems("2015/11").Visible = False
        .PivotItems("2015/12").Visible = False
        .PivotItems("2016/01").Visible = False
        .PivotItems("2016/02").Visible = False
        .PivotItems("2016/03").Visible = False
        .PivotItems("2016/04").Visible = False
        .PivotItems("2016/05").Visible = False
        .PivotItems("2016/06").Visible = False
        .PivotItems("2016/07").Visible = False
        .PivotItems("2016/08").Visible = False
        .PivotItems("2016/09").Visible = False
        .PivotItems("2016/10").Visible = False
        .PivotItems("2016/11").Visible = False
        .PivotItems("2016/12").Visible = False
        .PivotItems("2017/01").Visible = False
        .PivotItems("2017/02").Visible = False
        .PivotItems("2017/03").Visible = False
        .PivotItems("2017/04").Visible = False
        .PivotItems("2017/05").Visible = False
        .PivotItems("2017/06").Visible = False
        .PivotItems("2017/07").Visible = False
        .PivotItems("2017/08").Visible = False
        .PivotItems("2017/09").Visible = False
        .PivotItems("2017/10").Visible = False
        .PivotItems("2017/11").Visible = False
        .PivotItems("2017/12").Visible = False
        .PivotItems("2018/01").Visible = False
        .PivotItems("2018/02").Visible = True
        .PivotItems("2018/03").Visible = False
        .PivotItems("2018/04").Visible = False
        .PivotItems("2018/05").Visible = False
        .PivotItems("2018/06").Visible = False
        .PivotItems("2018/07").Visible = False
        .PivotItems("2018/08").Visible = False
        .PivotItems("2018/09").Visible = False
        .PivotItems("2018/10").Visible = False
        .PivotItems("2018/11").Visible = False
        .PivotItems("2018/12").Visible = False
     
    End With
     
    If Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5").PivotFields("IGS").CurrentPage = "(All)" Then
     
        docWord.Bookmarks("DevisFact").Range.Text = "Aucun devis facturé sur le mois du rapport."
     
    Else
     
        Set Pvt = Worksheets("Rapport - Devis").PivotTables("Tableau croisé dynamique5")
        c = Pvt.TableRange2.Rows.Count
        c = c + 2
     
        If c = 7 Then 'c = 6
     
            docWord.Bookmarks("DevisFact").Range.Text = "Aucun devis facturé sur le mois du rapport."
     
        Else
     
            Sheets("Rapport - Devis").Range("N7:Q" & c + 1).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="DevisFact"                                                     'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    If Sheets("Rapport - Devis").PivotTables("Tableau croisé dynamique4").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        Sheets("Rapport - Devis").Range("F19:G32").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="DevisFactRecap"                                                    'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    Else
     
        Sheets("Rapport - Devis").Range("F4:G17").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="DevisFactRecap"                                                    'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------------   PRM   -----------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - PRM").PivotTables("Tableau croisé dynamique7").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("PRM").Range.Text = "Aucun dossier PRM transmis ou en cours."
     
    Else
     
        Set Pvt = Sheets("Rapport - PRM").PivotTables("Tableau croisé dynamique7")
        D = Pvt.TableRange2.Rows.Count
        D = D + 1
        Sheets("Rapport - PRM").Columns("C:C").ColumnWidth = 80
        Sheets("Rapport - PRM").Columns("D:D").ColumnWidth = 60
        'Sheets("Rapport - PRM").Cells.EntireRow.AutoFit
     
        Sheets("Rapport - PRM").Columns("C:D").Select
     
        With Selection
     
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
     
        End With
     
        If D = 5 Then ' D = 6
     
            docWord.Bookmarks("PRM").Range.Text = "Aucun dossier PRM transmis ou en cours."
     
        Else
     
            Sheets("Rapport - PRM").Range("A5:D" & D).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PRM"                                                           'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------   FICHE PROGRES 2   ------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique8").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("FPRetour").Range.Text = "Aucune FP n'a fait l'objet de retour de l'installation."
     
    Else
     
        Set Pvt = Sheets("Rapport - FP").PivotTables("Tableau croisé dynamique8")
        D = Pvt.TableRange2.Rows.Count
     
            If D = 5 Then 'D = 6
     
                docWord.Bookmarks("FPRetour").Range.Text = "Aucune FP n'a fait l'objet de retour de l'installation."
     
            Else
     
                Sheets("Rapport - FP").Range("K5:M" & D).Copy
                appWrd.Selection.Goto What:=wdGoToBookmark, Name:="FPRetour"                                                  'on recherche le signet dans Word pour se positionner
                appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
                Application.CutCopyMode = False
     
            End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------   INVENTAIRE   --------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - Inventaire").PivotTables("Tableau croisé dynamique17").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("InvenCou").Range.Text = ""
        docWord.Bookmarks("InvDebTri").Range.Text = ""
        docWord.Bookmarks("VarInv").Range.Text = "Aucun équipement MEM en compte."
        docWord.Bookmarks("Invgraph").Range.Text = "Aucun équipement MEM en compte."
     
    Else
     
        'Copier le 1er Graphique
        Sheets("Rapport - Inventaire").ChartObjects("Graphique 1").Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="Invgraph"                                                          'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
        Sheets("Rapport - Inventaire").Range("I4:N10").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="VarInv"                                                            'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------   BT CP RETARD   ------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Sheets("Retard BT CP").ListObjects("Tableau_Rapport_aux_installations.accdb3").Range. _
        AutoFilter Field:=9, Criteria1:=("All")
    Sheets("Retard BT CP").ListObjects("Tableau_Rapport_aux_installations.accdb3").Range.AutoFilter Field:=10, Criteria1:=("All")
     
    DernLigne = Sheets("Retard BT CP").Range("A1048576").End(xlUp).Row
     
    Sheets("Retard BT CP").ListObjects("Tableau_Rapport_aux_installations.accdb3").Range. _
        AutoFilter Field:=9, Criteria1:=Sheets("Liste IGS").Range("B" & h).Value
    Sheets("Retard BT CP").ListObjects("Tableau_Rapport_aux_installations.accdb3").Range.AutoFilter Field:=10, Criteria1:=Sheets("Accueil").Range("N10").Value
     
    NBLIGNEBT = 0
    NBLIGNEBT = Sheets("Retard BT CP").Range("A1:A" & Sheets("Retard BT CP").Range("A1048576").End(xlUp).Row).SpecialCells(xlVisible).Count
     
    If NBLIGNEBT = 1 Then
     
        docWord.Bookmarks("BTCPRet").Range.Text = "Aucun BT CP en retard sur le mois du rapport."
     
    Else
     
        Sheets("Retard BT CP").Range("A1:G" & DernLigne).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="BTCPRet"                                                           'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------   FIR   ---------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Sheets("FIR").ListObjects("Tableau_Rapport_aux_installations.accdb2").Range. _
        AutoFilter Field:=10, Criteria1:=("All")
     
    DernLigne = Sheets("FIR").Range("A1048576").End(xlUp).Row
     
    Sheets("FIR").ListObjects("Tableau_Rapport_aux_installations.accdb2").Range. _
        AutoFilter Field:=10, Criteria1:=Sheets("Liste IGS").Range("B" & h).Value
    Sheets("FIR").ListObjects("Tableau_Rapport_aux_installations.accdb2").Range. _
        AutoFilter Field:=9, Criteria1:=Sheets("Accueil").Range("N10").Value
     
    NBLIGNEBT = 0
    NBLIGNEBT = Sheets("FIR").Range("A1:A" & Sheets("FIR").Range("A1048576").End(xlUp).Row).SpecialCells(xlVisible).Count
     
    If NBLIGNEBT = 1 Then
     
        docWord.Bookmarks("FIR").Range.Text = "Aucune FIR émise sur le mois du rapport."
     
    Else
     
        Sheets("FIR").Columns("D:D").ColumnWidth = 25#
        Sheets("FIR").Range("A1:H" & DernLigne).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="FIR"                                                               'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------------   PDR   -----------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique11").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("PDR").Range.Text = "Aucune demande d'approvisionnement PDR transmise à la CIM."
     
    Else
     
        Set Pvt = Worksheets("Rapport - PDR").PivotTables("Tableau croisé dynamique11")
        g = Pvt.TableRange1.Rows.Count
        g = 5 + g
     
        If g = 7 Then
     
            docWord.Bookmarks("PDR").Range.Text = "Aucune demande d'approvisionnement PDR transmise à la CIM."
     
        Else
     
            Sheets("Rapport - PDR").Range("A6:C" & g).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PDR"                                                           'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    appWrd.Visible = False
     
     
    ' ESSAI N°3 DE PIVOT ITEMS
    'With Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("Mois Fact")
    '
    '    For AnneeRapport = 2014 To ThisYear
    '
    '        For MoisRapport = 1 To 12
    '
    '            PvtItm = "" & AnneeRapport & "/" & MoisRapport & ""
    '
    '            If AnneeRapport = Year(Range(Sheets("Accueil").Cells("P10"))) Then
    '
    '                If MoisRapport = Month(Range(Sheets("Accueil").Cells("P10"))) Then
    '
    '                    .PivotItems(PvtItm).Visible = True
    '
    '                Else: .PivotItems(PvtItm).Visible = False
    '
    '                End If
    '
    '            End If
    '
    '        Next
    '
    '    Next
    '
    'End With
     
     
    ' ESSAI N°2 DE PIVOT ITEMS
    'PvtItms = "" & Worksheets("Accueil").Range("N10").Value & ""
    '
    'With Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("Mois Fact")
    '
    '    .PivotItems("/").Visible = False
    '    .PivotItems(PvtItms).Visible = True
    '
    'End With
     
     
    ' ESSAI N°1 DE PIVOT ITEMS
    With Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("Mois Fact")
     
        .PivotItems("/").Visible = False
        .PivotItems("2014/01").Visible = False
        .PivotItems("2014/02").Visible = False
        .PivotItems("2014/03").Visible = False
        .PivotItems("2014/04").Visible = False
        .PivotItems("2014/05").Visible = False
        .PivotItems("2014/06").Visible = False
        .PivotItems("2014/07").Visible = False
        .PivotItems("2014/08").Visible = False
        .PivotItems("2014/09").Visible = False
        .PivotItems("2014/10").Visible = False
        .PivotItems("2014/11").Visible = False
        .PivotItems("2014/12").Visible = False
        .PivotItems("2015/01").Visible = False
        .PivotItems("2015/02").Visible = False
        .PivotItems("2015/03").Visible = False
        .PivotItems("2015/04").Visible = False
        .PivotItems("2015/05").Visible = False
        .PivotItems("2015/06").Visible = False
        .PivotItems("2015/07").Visible = False
        .PivotItems("2015/08").Visible = False
        .PivotItems("2015/09").Visible = False
        .PivotItems("2015/10").Visible = False
        .PivotItems("2015/11").Visible = False
        .PivotItems("2015/12").Visible = False
        .PivotItems("2016/01").Visible = False
        .PivotItems("2016/02").Visible = False
        .PivotItems("2016/03").Visible = False
        .PivotItems("2016/04").Visible = False
        .PivotItems("2016/05").Visible = False
        .PivotItems("2016/06").Visible = False
        .PivotItems("2016/07").Visible = False
        .PivotItems("2016/08").Visible = False
        .PivotItems("2016/09").Visible = False
        .PivotItems("2016/10").Visible = False
        .PivotItems("2016/11").Visible = False
        .PivotItems("2016/12").Visible = False
        .PivotItems("2017/01").Visible = False
        .PivotItems("2017/02").Visible = False
        .PivotItems("2017/03").Visible = False
        .PivotItems("2017/04").Visible = False
        .PivotItems("2017/05").Visible = False
        .PivotItems("2017/06").Visible = False
        .PivotItems("2017/07").Visible = False
        .PivotItems("2017/08").Visible = False
        .PivotItems("2017/09").Visible = False
        .PivotItems("2017/10").Visible = False
        .PivotItems("2017/11").Visible = False
        .PivotItems("2017/12").Visible = False
        .PivotItems("2018/01").Visible = False
        .PivotItems("2018/02").Visible = True
        .PivotItems("2018/03").Visible = False
        .PivotItems("2018/04").Visible = False
        .PivotItems("2018/05").Visible = False
        .PivotItems("2018/06").Visible = False
        .PivotItems("2018/07").Visible = False
        .PivotItems("2018/08").Visible = False
        .PivotItems("2018/09").Visible = False
        .PivotItems("2018/10").Visible = False
        .PivotItems("2018/11").Visible = False
        .PivotItems("2018/12").Visible = False
     
    End With
     
    If Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10").PivotFields("IGS").CurrentPage = "(All)" Then
     
        docWord.Bookmarks("PDRFact").Range.Text = "Aucune PDR facturée sur le mois du rapport."
     
    Else
     
        Set Pvt = Worksheets("Rapport - PDR").PivotTables("Tableau croisé dynamique10")
        g = Pvt.TableRange1.Rows.Count
        g = 5 + g
     
        If g = 7 Then
     
            docWord.Bookmarks("PDRFact").Range.Text = "Aucune PDR facturée sur le mois du rapport."
     
        Else
     
            Sheets("Rapport - PDR").Range("M6:O" & g).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PDRFact"   ' on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    If Sheets("Rapport - PDR").PivotTables("Tableau croisé dynamique9").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        Sheets("Rapport - PDR").Range("E19:F32").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PDRFactRecap"                                                      'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    Else
     
        Sheets("Rapport - PDR").Range("E4:F17").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PDRFactRecap"                                                      'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- RAD RAD RAD RAD--------------------------------------------------------------------   INVENTAIRE   RAD  ---------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - INV RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("InvRad").Range.Text = "Aucun équipement EER en compte."
        docWord.Bookmarks("INVRADMAINT").Range.Text = "Aucun équipement EER en compte."
     
    Else
     
        Sheets("Rapport - INV RAD").Range("I4:O10").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="InvRad"                                                            'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
        Sheets("Rapport - INV RAD").ChartObjects("Graphique 1").Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="INVRADMAINT"                                                       'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- RAD RAD RAD RAD--------------------------------------------------------------------   BT CP RAD POR   -----------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Liste IGS").Range("K" & h) = "Conditionnelle" Then
     
        docWord.Bookmarks("RadBTATPLATEXT1").Range.Text = ""
        docWord.Bookmarks("RadBTATPLATEXT2").Range.Text = "La maintenance des équipements portables de l'installation est sur un mode conditionnel et est géré directement par le SPR, via COMPERE."
        docWord.Bookmarks("RadBTATPLATEXT3").Range.Text = ""
        docWord.Bookmarks("RadBTATPLATotal").Range.Text = ""
     
    Else
     
        If Sheets("Rapport - BT RAD POR").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
            CurrentPage = "(All)" Then
     
            docWord.Bookmarks("RadBTATPLATEXT1").Range.Text = "Afin que les maintenances préventives sur le matériel portable puissent être réalisées, il est nécessaire que ces équipements soient mis à disposition du contrat EER pour contrôle périodique."
            docWord.Bookmarks("RadBTATPLATEXT2").Range.Text = "Un mail mensuel à destination des chefs d'installation est envoyé par la CIM afin de rappeler la liste des BT ouverts. "
            docWord.Bookmarks("RadBTATPLATEXT3").Range.Text = "Vous trouverez ci-dessous la volumétrie des BT en statut "" L "" sous Infor ("" Attente de planification "") concernant votre IGS (détail présent dans le mail mensuel de la CIM) :"
            docWord.Bookmarks("RadBTATPLATotal").Range.Text = "Aucun BT CP sur des équipements portables."
     
        Else
     
            docWord.Bookmarks("RadBTATPLATEXT1").Range.Text = "Afin que les maintenances préventives sur le matériel portable puissent être réalisées, il est nécessaire que ces équipements soient mis à disposition du contrat EER pour contrôle périodique."
            docWord.Bookmarks("RadBTATPLATEXT2").Range.Text = "Un mail mensuel à destination des chefs d'installation est envoyé par la CIM afin de rappeler la liste des BT ouverts. "
            docWord.Bookmarks("RadBTATPLATEXT3").Range.Text = "Vous trouverez ci-dessous la volumétrie des BT en statut "" L "" sous Infor ("" Attente de planification "") concernant votre IGS (détail présent dans le mail mensuel de la CIM) :"
            Sheets("Rapport - BT RAD POR").Range("G5:L18").Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="RadBTATPLATotal"                                                   'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- RAD RAD RAD RAD------------------------------------------------------------------------   PRM   -----------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - PRM EER").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("PRMEER").Range.Text = "Aucun dossier PRM EER transmis ou en cours."
        D = 0
     
    Else
     
        Set Pvt = Sheets("Rapport - PRM EER").PivotTables("Tableau croisé dynamique1")
        D = Pvt.TableRange2.Rows.Count
        D = D + 1
        Sheets("Rapport - PRM EER").Columns("C:C").ColumnWidth = 80
        Sheets("Rapport - PRM EER").Columns("D:D").ColumnWidth = 60
        'Sheets("Rapport - PRM EER").Cells.EntireRow.AutoFit
     
        Sheets("Rapport - PRM EER").Columns("C:D").Select
     
        With Selection
     
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
     
        End With
     
        If D = 6 Then
     
            docWord.Bookmarks("PRMEER").Range.Text = "Aucun dossier PRM EER transmis ou en cours."
     
        Else
     
            Sheets("Rapport - PRM EER").Range("A3:D" & D - 2).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PRMEER"                                                        'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------------   BT RE   ---------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Set Pvt = Worksheets("Rapport - BT RE RAD").PivotTables("Tableau croisé dynamique1")
    A = Pvt.TableRange2.Rows.Count
    A = A + 2
     
    If Sheets("Rapport - BT RE RAD").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("RadBTRE").Range.Text = "Aucun BT RE sur l'année du rapport."
     
    Else
     
        If Sheets("Rapport - BT RE RAD 2").Range("N27") = "" Then
     
            docWord.Bookmarks("RadBTRE").Range.Text = "Aucun BT RE sur l'année du rapport."
     
        Else
     
            Sheets("Rapport - BT RE RAD 2").Range("$B$2:$N$27").AutoFilter Field:=14, Criteria1:="<>"
            Sheets("Rapport - BT RE RAD 2").Range("A3:N27").Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="RadBTRE"                                                       'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--- TEA TEA TEA TEA TEA  ------------------------------------------------------------------------   INVENTAIRE TEA   ------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - INV TEA").PivotTables("Tableau croisé dynamique2").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("InventaireTEA").Range.Text = "Aucun équipement EES en compte."
     
    Else
     
        Set Pvt = Sheets("Rapport - INV TEA").PivotTables("Tableau croisé dynamique2")
        D = Pvt.TableRange2.Rows.Count
     
        If D = 5 Then
     
            docWord.Bookmarks("InventaireTEA").Range.Text = "Aucun équipement EES en compte."
     
        Else
     
            Sheets("Rapport - INV TEA").ChartObjects("Graphique 1").Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="InventaireTEA"                                                 'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------   CAMPAGNE TEA   ------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Sheets("Campagne TEA").ListObjects("Tableau_Rapport_aux_installations.accdb10").Range. _
        AutoFilter Field:=8, Criteria1:="(All)"
     
    DernLigne = Sheets("Campagne TEA").Range("A1048576").End(xlUp).Row
     
    Sheets("Campagne TEA").ListObjects("Tableau_Rapport_aux_installations.accdb10").Range. _
        AutoFilter Field:=8, Criteria1:=Sheets("Liste IGS").Range("B" & h).Value
     
    NBLIGNEBT = 0
    NBLIGNEBT = Sheets("Campagne TEA").Range("A1:A" & Sheets("Campagne TEA").Range("A1048576").End(xlUp).Row).SpecialCells(xlVisible).Count
     
    If NBLIGNEBT = 1 Then
     
     
        docWord.Bookmarks("CampagneTEA").Range.Text = "Aucun BT CP en retard sur le mois du rapport."
     
    Else
     
        Sheets("Campagne TEA").Range("A1:G" & DernLigne).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="CampagneTEA"                                                       'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- TEA TEA TEA TEA -----------------------------------------------------------------------   PRM   -----------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - EES PRM").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("PRMEES").Range.Text = "Aucun dossier PRM EES transmis ou en cours."
        D = 0
     
    Else
     
        Set Pvt = Sheets("Rapport - EES PRM").PivotTables("Tableau croisé dynamique1")
        D = Pvt.TableRange2.Rows.Count
        D = D + 1
        Sheets("Rapport - EES PRM").Columns("D:D").ColumnWidth = 80
        Sheets("Rapport - EES PRM").Columns("E:E").ColumnWidth = 60
        'Sheets("Rapport - EES PRM").Cells.EntireRow.AutoFit
     
        Sheets("Rapport - EES PRM").Columns("C:E").Select
     
        With Selection
     
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
     
        End With
     
        If D = 6 Then
     
            docWord.Bookmarks("PRMEES").Range.Text = "Aucun dossier PRM EES transmis ou en cours."
     
        Else
     
            Sheets("Rapport - EES PRM").Range("A3:E" & D - 2).Copy
            appWrd.Selection.Goto What:=wdGoToBookmark, Name:="PRMEES"                                                        'on recherche le signet dans Word pour se positionner
            appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
            Application.CutCopyMode = False
     
        End If
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- TEA TEA TEA TEA--------------------------------------------------------------------   BT TEA   ------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    If Sheets("Rapport - TEA BT").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("BTTEA").Range.Text = "Aucun BT EES sur le mois du rapport."
     
    Else
     
        Sheets("Rapport - TEA BT").Range("M9:S22").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="BTTEA"   ' on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    appWrd.Visible = False
     
    DernLigne = Sheets("TEA - Campagne Ecarts").Range("A1048576").End(xlUp).Row
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------------   MEMPVI   --------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Set Pvt = Worksheets("Rapport - MEMPVI").PivotTables("Tableau croisé dynamique1")
    A = Pvt.TableRange2.Rows.Count
    A = A + 2
     
    If Worksheets("Rapport - MEMPVI").PivotTables("Tableau croisé dynamique1").PivotFields("IGS"). _
        CurrentPage = "(All)" Then
     
        docWord.Bookmarks("MEMPVIRAD").Range.Text = "Aucune pompe à vide dans l'inventaire EER de votre installation."
     
    Else
     
        Sheets("Rapport - MEMPVI 2").Range("$B$2:$F$38").AutoFilter Field:=5, Criteria1:="<>"
        Sheets("Rapport - MEMPVI 2").Range("B3:F38").Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="MEMPVIRAD"                                                         'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '--------------- TEA TEA TEA TEA--------------------------------------------------------------------   BT RE TEA   ---------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=7, Criteria1:="(All)"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=8, Criteria1:="(All)"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=9, Criteria1:="(All)"
     
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=7, Criteria1:=Sheets("Liste IGS").Range("B" & h).Value
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=8, Criteria1:=Array("AI", "AM", "DA"), Operator:=xlFilterValues
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=9, Criteria1:=Sheets("Accueil").Range("N10").Value
     
    NBLIGNEBT = 0
    NBLIGNEBT = Sheets("TEA - Campagne Ecarts").Range("A1:A" & Sheets("TEA - Campagne Ecarts").Range("A1048576").End(xlUp).Row).SpecialCells(xlVisible).Count
     
    If NBLIGNEBT < 2 Then
     
        docWord.Bookmarks("BTAITEA").Range.Text = "Aucun BT d'assistance sur le mois du rapport."
     
    Else
     
        Sheets("TEA - Campagne Ecarts").Range("A1:F" & DernLigne).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="BTAITEA"                                                           'on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=7, Criteria1:="(All)"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=8, Criteria1:="(All)"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=9, Criteria1:="(All)"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=7, Criteria1:=Sheets("Liste IGS").Range("B" & h).Value
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=8, Criteria1:="RE"
    Sheets("TEA - Campagne Ecarts").ListObjects("Tableau_Rapport_aux_installations.accdb6").Range. _
        AutoFilter Field:=9, Criteria1:=Sheets("Accueil").Range("N10").Value
     
    NBLIGNEBT = 0
    NBLIGNEBT = Sheets("TEA - Campagne Ecarts").Range("A1:A" & Sheets("TEA - Campagne Ecarts").Range("A1048576").End(xlUp).Row).SpecialCells(xlVisible).Count
     
    If NBLIGNEBT < 2 Then
     
        docWord.Bookmarks("BTRETEA").Range.Text = "Aucun BT RE sur le mois du rapport."
     
    Else
     
        Sheets("TEA - Campagne Ecarts").Range("A1:F" & DernLigne).Copy
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:="BTRETEA"   ' on recherche le signet dans Word pour se positionner
        appWrd.Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        Application.CutCopyMode = False
     
    End If
     
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------- Enregistrement -------------------------------------------------------------------------------------------------
    '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    appWrd.ActiveDocument.SaveAs FileFormat:=17, Filename:="\\lurs\_partage\Maint\CIM\MEM\07 - Suivi  - Amélioration continue\03 - Reporting\Rapport aux installations\Rapports générés\" & Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018"
    appWrd.ActiveDocument.SaveAs "\\lurs\_partage\Maint\CIM\MEM\07 - Suivi  - Amélioration continue\03 - Reporting\Rapport aux installations\Rapports générés\" & Sheets("Liste IGS").Range("D" & h).Value & " - " & Sheets("Accueil").Range("L10").Value & "-2018"
    appWrd.ActiveDocument.Close
     
    Set truc = New DataObject
    truc.SetText ""
    truc.PutInClipboard
    Set truc = Nothing
     
    End If
     
    Next
     
    MsgBox ("Les rapports ont été générés.")
     
    End Sub
    Merci d'avance aux courageux qui voudront bien m'aider à trouver la solution !

  2. #2
    Expert éminent Avatar de Menhir
    Homme Profil pro
    Ingénieur
    Inscrit en
    Juin 2007
    Messages
    16 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 16 037
    Par défaut
    Citation Envoyé par YanLeFlan Voir le message
    Et, depuis, ma macro fonctionne mais ne remplit plus mon fichier Word.
    Commence par supprimer les On Error et ton code t'indiquera où se trouve le problème plutôt que de rester muet.

  3. #3
    Membre averti
    Homme Profil pro
    Conseil en assistance à maîtrise d'ouvrage
    Inscrit en
    Septembre 2014
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Conseil en assistance à maîtrise d'ouvrage
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2014
    Messages : 33
    Par défaut
    Merci pour ce premier élément !

    Tout d'abord, il a buggué sur les lignes 97 et 98 car elles font appel à l'onglet Sheets("Rapport - BT ATPLA RAD") qui n'existe plus... J'ai donc mis en commentaire les deux lignes dans ma macro.

    Ensuite, et c'est peut être le nœud du problème, au niveau de la ligne 119 (et, au final, sur les suivantes qui contiennent l'instruction docWord.Bookmarks), la macro me renvoie l'erreur "Erreur d'exécution '6124': Impossible de modifier cette sélection car elle est protégée.". Il semble donc qu'il considère mon fichier Word comme protégé en lecture... Ce fichier n'a pas été modifié depuis (sauf le passage à Office 2016, s'entend). Je sais pas trop où trouver la parade, du coup !

  4. #4
    Expert éminent Avatar de Menhir
    Homme Profil pro
    Ingénieur
    Inscrit en
    Juin 2007
    Messages
    16 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 16 037
    Par défaut
    Citation Envoyé par YanLeFlan Voir le message
    Je sais pas trop où trouver la parade, du coup !
    Mais au moins tu sais dans quelle direction chercher.

    la macro me renvoie l'erreur "Erreur d'exécution '6124': Impossible de modifier cette sélection car elle est protégée.". Il semble donc qu'il considère mon fichier Word comme protégé en lecture...
    Ne serait-ce pas à cause du ReadOnly:=True à l'ouverture du Doc ?

  5. #5
    Membre averti
    Homme Profil pro
    Conseil en assistance à maîtrise d'ouvrage
    Inscrit en
    Septembre 2014
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Conseil en assistance à maîtrise d'ouvrage
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2014
    Messages : 33
    Par défaut
    Merci à vous pour ces indications, ma macro peut maintenant remplir le fichier doc et le sauvegarder.

    En revanche, au cours de la procédure, la macro s'interrompt une cinquantaine de fois, au moment des lignes Sheets("xxx").PivotTables("Tableau croisé dynamiquexxx").PivotCache.Refresh et Sheets("xxx").PivotTables("Tableau croisé dynamiquexxx").PivotFields("IGS").ClearAllFilters.

    Nom : Presse-papiers-1.jpg
Affichages : 668
Taille : 26,8 Ko

    Bon, cela passe à la ligne suivante en cliquant simplement sur Continuer, mais j'aimerai ne plus avoir à intervenir au cours de la génération des rapports. Avez-vous une idée de ce qui ne va pas ?

  6. #6
    Expert éminent Avatar de Menhir
    Homme Profil pro
    Ingénieur
    Inscrit en
    Juin 2007
    Messages
    16 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 16 037
    Par défaut
    Je n'ai jamais géré de de TCD en VBA.
    De plus, à priori le problème vient du contenu de ta feuille de calcul.

    Le seul conseil que je peux te donner c'est de trouver la source du problème plutôt que de cacher la poussière sous le tapis comme c'était le cas avec le On Error qui était dans ton code.

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

Discussions similaires

  1. Passage de l'Office 2010 à l'Office 365
    Par yannick.delloge dans le forum Access
    Réponses: 0
    Dernier message: 03/06/2016, 10h04
  2. [2010] Migration Office 2010 vers Office 365
    Par olibara dans le forum Microsoft Office
    Réponses: 3
    Dernier message: 06/02/2016, 21h48
  3. [XL-2013] Biliothèques Office 2010 et Office 2013
    Par Daejung dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 25/01/2016, 16h35
  4. [2010] apparence Office 2007 pour office 2010
    Par logan139 dans le forum Microsoft Office
    Réponses: 4
    Dernier message: 26/11/2011, 10h50
  5. Office 2007 et Office 2010
    Par Pasqualini dans le forum Word
    Réponses: 1
    Dernier message: 30/11/2009, 14h13

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