bonjours,

Alors après avoir déployer mon application et mis en production, j'ai fait une série de test sur l'ordinateur de mon client et le programme plante au moment ou je veux parcourir l'ordinateur avec une openFileDialog j ai alors comme erreur (je vais essayer d'être clair) :
"Une exception non gérée s'est produite dans votre application si vous cliquez sur continuer[...]. Impossible de charger le fichier ou l'assembly Microsoft.Office.Interrop.Word, Version=12.0.0.0, Culture=neutral, PublicKey=Token=71e9bce111e9439c' ou une de ses dépendances. Le fichier specifié est introuvable.
Je tien à signaler que je développe sous Seven et que l'application va tourner sur un XP.

Je vous met la routine qui fait cela :
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
 
Public Sub convertirEnImage(ByVal idPage As String, ByVal sequence As Integer, ByVal typeTexte As String)
 
        Dim choisirFichier As New OpenFileDialog
        Dim cheminFichier As String = String.Empty
        Dim fichier As String = String.Empty
        Dim tmp As String()
 
        With choisirFichier
            .InitialDirectory = "c:\"
            .Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
            .FilterIndex = 2
            .RestoreDirectory = True
            .ShowDialog()
        End With
 
        cheminFichier = choisirFichier.FileName
        fichier = choisirFichier.SafeFileName
        tmp = choisirFichier.SafeFileName.Split("."c)
        choisirFichier.Dispose()
 
        If tmp(0) <> "" Then
 
            Dim objWord As New Microsoft.Office.Interop.Word.Application
            Dim objDoc As Microsoft.Office.Interop.Word.Document
            'Dim print As Printer
 
            objWord = CreateObject("Word.Application")
            'le document word est visible
            objWord.Visible = True
            objDoc = objWord.Documents.Open(cheminFichier)
            'affiche tout le document sur une page
            objDoc.ActiveWindow.ActivePane.View.Zoom.PageFit = Microsoft.Office.Interop.Word.WdPageFit.wdPageFitFullPage
            'objDoc.PageSetup.PageWidth + 356
 
            Dim b As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Imaging.PixelFormat.Format32bppArgb)
 
 
 
            ' créer un objet graphique qui prendra le screenshot
            Dim gfx As Graphics = Graphics.FromImage(b)
 
 
            'copie du contenu de l'ecran 
            'Screen.PrimaryScreen.Bounds.Size
 
            gfx.CopyFromScreen(My.Computer.Screen.Bounds.X, My.Computer.Screen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
 
            tmp(0) = tmp(0) & ".jpg"
 
            'verifie l'existence du repertoire
            If Dir("C:\image", vbDirectory) = "" Then
                'si le repertoire n existe pas on le créer
                MkDir("C:\image")
            End If
 
            If My.Computer.Screen.Bounds.Width = 1440 Then
                ' Rectangle -> x,y points et largeur et hauteur
                Dim rectangle As New Rectangle(477, 155, 474, 667)
                b = b.Clone(rectangle, b.PixelFormat)
            ElseIf My.Computer.Screen.Bounds.Width = 1280 And My.Computer.Screen.Bounds.Height = 1024 Then
                Dim rectangle As New Rectangle(430, 156, 472, 671)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1280 And My.Computer.Screen.Bounds.Height = 960 Then
                Dim rectangle As New Rectangle(380, 156, 472, 671)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1280 And My.Computer.Screen.Bounds.Height = 768 Then
                Dim rectangle As New Rectangle(441, 153, 382, 539)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1280 And My.Computer.Screen.Bounds.Height = 720 Then
                Dim rectangle As New Rectangle(441, 153, 382, 539)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1280 And My.Computer.Screen.Bounds.Height = 600 Then
                Dim rectangle As New Rectangle(500, 150, 267, 376)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1152 And My.Computer.Screen.Bounds.Height = 864 Then
                Dim rectangle As New Rectangle(345, 145, 447, 632)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 1024 And My.Computer.Screen.Bounds.Height = 768 Then
                Dim rectangle As New Rectangle(314, 153, 382, 539)
                b = b.Clone(rectangle, b.PixelFormat)
 
            ElseIf My.Computer.Screen.Bounds.Width = 800 And My.Computer.Screen.Bounds.Height = 600 Then
                Dim rectangle As New Rectangle(260, 151, 267, 376)
                b = b.Clone(rectangle, b.PixelFormat)
 
            End If
 
 
 
            ' sauvegarde le resultat a l'endroit demandé sous ke format demandé
            b.Save("C:\image\" & tmp(0), Imaging.ImageFormat.Jpeg)
 
            objWord.Documents.Close()
            objWord.Quit()
 
            cheminFichier = "C:\image\" & tmp(0)
 
            methode_base_de_donee.ajouterFichier(cheminFichier, "img/" & tmp(0))
 
            methode_base_de_donee.AjouterEnregistrement(idPage, sequence, typeTexte, , tmp(0), , , )
 
            MessageBox.Show("Ajout correctement effectué", "Succés", MessageBoxButtons.OK, MessageBoxIcon.Information)
 
            'parcourt de tout les processus ouvert sur la machine
            For Each Processus As Process In Process.GetProcesses()
                'si le processus WINWORD est actif
                If Processus.ProcessName.EndsWith("WINWORD") Then
                    With Processus
                        'on kill le process
                        .Kill()
                        'libère les ressources
                        .Close()
                    End With
                End If
            Next
        Else
            MessageBox.Show("Annulé")
        End If
 
 
    End Sub
En espèrent que vous puissiez m'aider sur ce problème, bien à vous.