Bonjour,

J'ai un problème de pilotage de Word 2000 avec Delphi 7 sous Windows Server 2008 64 bits :
j'ai fait un petit exécutable qui me permet d'imprimer un fichier doc sur une imprimante donnée. Lorsque je me connecte en tant qu'administrateur et que je lance cet executable en cliquant sur un .bat, je n'ai pas de problème, le fichier s'imprime bien.
En revanche, lorsque j'appelle ce programme depuis un autre programme Delphi (qui tourne en permanence sur le serveur), j'obtiens un message d'erreur "L'appel a été rejeté par l'appelé" ou bien "Le filtre de messages indiquait que l'application était occupée". Le problème survient à l'ouverture du doc.
Pourtant dans les deux cas, mon exécutable qui imprime le .doc est lancé en administrateur !
A noter que je ne rencontrais pas ce problème sous Windows 2000 Serveur.

Voici le code que j'utilise pour imprimer le fichier doc :
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
 
     wordApplication1 := TwordApplication.Create(nil);
 
     // ouverture du fichier
     FileName := ParamStr(1); // ou .rtf ...
     Visible := True;  // Le serveur COM est affiché
     WordApplication1.Documents.Open(FileName, EmptyParam, EmptyParam,
               					 EmptyParam, EmptyParam, EmptyParam, 
                                                 EmptyParam,EmptyParam, EmptyParam,
                                                 EmptyParam, EmptyParam, Visible);
 
     // impression
     Range:=wdPrintAllDocument; // page Courante  = wdPrintCurrentPage, ...
     PageType:=wdPrintAllPages; // pages impaires = wdPrintOddPagesOnly, ...
     Background:=False;
     wordApplication1.ActivePrinter := 'PDF-XChange Lite 3.0';
 
     WordApplication1.ActiveDocument.PrintOut(BackGround,EmptyParam,
                                              Range,
                                              EmptyParam,EmptyParam,EmptyParam,
                                              EmptyParam,EmptyParam,EmptyParam,
                                              PageType,
                                              EmptyParam,EmptyParam,EmptyParam,
                                              EmptyParam,EmptyParam,EmptyParam,
                                              EmptyParam,EmptyParam);
 
     l_dot := string('C:\Users\Administrateur.TEST-2008\AppData\Roaming\Microsoft\Modèles\Normal.dot');
     wordApplication1.activeDocument.Set_AttachedTemplate(l_dot);
 
     SaveChanges := WdDoNotSaveChanges;
     OriginalFormat := UnAssigned;
     RouteDocument := UnAssigned;
     wordApplication1.ActiveDocument.Close(SaveChanges,OriginalFormat,RouteDocument);
 
     // fermeture
     SaveChanges := WdDoNotSaveChanges;
     OriginalFormat := wdOpenFormatAuto;
     RouteDocument := UnAssigned;
     wordApplication1.Quit(SaveChanges,OriginalFormat,RouteDocument);
     wordApplication1.Free;