Bonjour à tous,

Je suis à nouveau sur un nouveau projet VBA mais cette fois-ci sur Word.

J'ai récupérer un code sous un de mes projets Excel qui me permet de sélectionner une image, de la redimensionner et l'insérer dans un objet image. Cela fonctionne parfaitement sous Excel mais sous Word, j'ai un problème de raffraichissement. En effet, le code fonctionne parfaitement mais je suis dans l’obligation de rabaisser la fenêtre de Word et la remettre à l'ecran afin de voir la photo affichée ou inversement de la voir supprimée.

Voici mon code :

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
Dim strFilePath As String
 
 If Image2.Picture Is Nothing Then
 
    With Application.FileDialog(msoFileDialogFilePicker)
        ' show the file picker dialog box
        If .Show <> 0 Then
            strFilePath = .SelectedItems(1)
 
 
Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
Img.LoadFile strFilePath
IP.Filters.Add IP.FilterInfos("Scale").FilterID
IP.Filters(1).Properties("MaximumWidth") = 96
IP.Filters(1).Properties("MaximumHeight") = 129
Set Img = IP.Apply(Img)
 
Image2.Picture = LoadPicture(strFilePath)
 
 
        End If
    End With
 
    Else
If MsgBox("Souhaitez-vous supprimer la photo", vbQuestion + vbYesNo) = vbYes Then
  Image2.Picture = LoadPicture()
 
  Else
  Exit Sub
  End If
End If
Merci d'avance pour votre aide et excellente journée.

JORDAN M.