Bonjour à tous !

Je viens à vous car je rencontre un problème assez pénible avec un bout de code VBA depuis mon passage de Word 2007 à Word 2010.

Sous 2007, le bout de code suivant fonctionnait parfaitement et me permettait d'inclure automatiquement toutes les images d'un document dans ce document (le fichier Word est généré par une autre appli qui enregistre les images séparément).

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
    'First, embed all document images in Word file
    With ActiveDocument
        ' embed linked InlineShapes
        For idx = .InlineShapes.Count To 1 Step -1
            Set oILS = .InlineShapes(idx)
            If Not oILS.LinkFormat Is Nothing Then
                oILS.LinkFormat.SavePictureWithDocument = True
                oILS.LinkFormat.BreakLink
            End If
        Next
 
        ' embed linked Shapes
        For idx = .Shapes.Count To 1 Step -1
            Set oShp = .Shapes(idx)
            If Not oShp.LinkFormat Is Nothing Then
                oShp.LinkFormat.SavePictureWithDocument = True
                oShp.LinkFormat.BreakLink
            End If
        Next
    End With
Sous 2010, j'obtiens l'erreur suivante :
Run-time error '5352'
The link does not exist.
Après investigation, il semblerait que la méthode LinkFormat retourne désormais un objet en lecture seule (alors qu'en 2007 et avant, cet objet pouvait être modifié).

Quelqu'un saurait comment contourner ce problème ou forcer l'objet LinkFormat à accepter les modifs ?

D'avance merci !


SP