Bonjour,

je reçois "unable to get the Insert property of The Picture Class" sur l'instruction en gras du code suivant :

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
Sub Format()
Dim pcx_name As String

For i = 5 To 561
    pcx_name = "G:\Emballage\Profiles\" & ActiveSheet.Range("A" & i) & ".PCX"
    Range("B" & i).Select
    
    ActiveSheet.Pictures.Insert(pcxname).Select
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 42.75
    Selection.ShapeRange.Width = 57.75
    Selection.ShapeRange.Rotation = 0#
    Rows(i).Select
    Selection.RowHeight = 48
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    
 Next
 
 End Sub
Faut-il une référence spéciale dans VBA ?
La Variable PCXname vaut "G:\Emballage\Profiles\03442.PCX".
L'image existe bien.

le code suivant enrégistré par l'enregistreur de macro fonctionne.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
    Range("B5").Select
    ActiveSheet.Pictures.Insert("G:\Emballage\Profiles\03442.PCX").Select
merci pour votre aide