Bonjour,
J'ai fait une macro afin de copier des tableaux Excel dans Word en format image.
Ma macro fonctionne bien...une fois sur deux! Avec exactement les mêmes données parfois je tombe sur une erreur 4605 "La méthode PasteSpecial de l'object Selection a échoué". Et ca ne plante jamais sur le même tableau.
Je précise que mes tableaux ont parfois des lignes cachées.
Voici mon code avec un exemple de copie de deux tableaux :
Merci par avance de votre aide !
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 'Création fichier WORD Application.DefaultSaveFormat = xlOpenXMLWorkbook Dim appWrd As Word.Application Dim docWrd As Word.Document Set appWrd = New Word.Application appWrd.Visible = True appWrd.DefaultSaveFormat = xlOpenXMLWorkbook Set docWrd = appWrd.Documents.Add 'Copie du premier tableau Sheets("Rendu").Range("A8:K50").Copy appWrd.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _ Placement:=wdInLine, DisplayAsIcon:=False Application.CutCopyMode = False 'Copie du second tableau Sheets("Rendu").Range("A54:K132").Copy appWrd.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _ Placement:=wdInLine, DisplayAsIcon:=False Application.CutCopyMode = False Set docWrd = Nothing Set appWrd = Nothing






Répondre avec citation
Partager