Bonjour,

Je n'arrive pas à fermer word proprement, lors de la génération des 1000 documents sur mon serveur, je trouve tous les winword qui ne sont pas fermés, est ce qu'il y a un moyen de fermer ces processus, car je ne comprends pas pourquoi ils sont toujours ouvert, merci infiniment de votre aide.
NB : j'ai un warning aux lignes 37 et 38 :
Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close
Est ce que c'est l'origine de mon problème?

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
 
 public void FUSION(string s)
        {
 
                Console.Write("1");
 
                String[] tbStr2 = s.Split(new Char[] { ';' });
                string nb = tbStr2[0];
                Object oMissing = System.Reflection.Missing.Value;
                Object oTrue = true;
                Object oFalse = false;
                Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
                oWord.Visible = true;
                oWord.Visible = false;
                Object oTemplatePath = modelee;
                oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
                bool sympb = false; bool E = false; bool n = false; bool p = false; bool r = false;
 
foreach (Microsoft.Office.Interop.Word.Range range in oWordDoc.Words)
                {if (range.Text.Trim().Contains("$"))
                    {   int pos = range.Text.Trim().IndexOf("$");
                        string str = range.Text.Trim().Replace("$", "");
                        range.Text = str;} }
 
                foreach (Microsoft.Office.Interop.Word.Range range in oWordDoc.Words)
                {if (range.Text.Trim().Contains("$$"))
                    {   int pos = range.Text.Trim().IndexOf("$$");
                        string str = range.Text.Trim().Replace("$$", "");
                        range.Text = str;} }
 
                Object oSaveAsFile ="./1.doc";
                oWordDoc.SaveAs(ref oSaveAsFile, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing);
                oWordDoc.Close(ref oFalse, ref  oMissing, ref oMissing);
                oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
 
 
 
 
        }