Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.07.31;
Скачать: CL | DM;

Вниз

Как подождать пока Word напечатает документ?   Найти похожие ветки 

 
SergP.   (2005-07-12 18:45) [0]

Нужно с консольного приложения распечатать 2 документа WORD
проблема в том что программа пытается закрыть Ворд до того как тот закончит печатать.


...
var
db,md:string;
...

db:=...
...
mb:=...

...
    CoInitialize(nil);
    Word:=CreateOleObject("Word.Application");
//     word.visible:=true;
    Word.Documents.Open (db,
                          true, false, false,
                          "", "", false,
                          "", "", wdOpenFormattext);
                         Word.ActiveDocument.FitToPages ;
                         Word.ActiveDocument.PrintOut;
                         Word.ActiveDocument.Close;

     Word.Documents.Open (mb,
                          true, false, false,
                          "", "", false,
                          "", "", wdOpenFormattext);
                         Word.ActiveDocument.PrintOut;
                         Word.ActiveDocument.Close;
                         Word.Quit;

   Couninitialize;
...


Как сделать сабж?


 
SergP ©   (2005-07-13 04:54) [1]

пытался было перед открытием документа отключить фоновую печать, а перед закрытием ворда включить, но что-то не получается.

Ставил sleep(10000) - тогда есно все работает, но ИМХО это не совсем верное решение.

Есть ли все-таки нечто, позволяющее узнать закончил ли ВОРД фоновую печать?


 
MBo ©   (2005-07-13 07:47) [2]

Isn"t it possible to use "Get_BackgroundPrintingStatus" or
something like that to terminate the job when it is done?
>>

Yes. You can turn background printing off altogether using
the Application.Options.PrintBackground property (just set
it to false), or you can poll the
Application.BaskgroundPrintingStatus property, which
returns the count of Word print jobs outstanding - when
it"s 0, quit.

--

еще одно:
The Windows print spooler regularly broadcasts a system wide
WM_SPOOLERSTATUS message each time a job is added or deleted from the
spooler que. The following example demonstrates trapping for this
message.

Example:

type
 TForm1 = class(TForm)
   Label1: TLabel;
 private
   { Private declarations }
   procedure WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS);
     message WM_SPOOLERSTATUS;
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS);
begin
 Lable1.Caption := IntToStr(msg.JobsLeft) +
                   " Jobs currenly in spooler";
 msg.Result := 0;
end;

Joe
--
Joe C. Hecht

Deborah Pate (Team JEDI)


 
SergP.   (2005-07-13 16:43) [3]

Спасибо. воспользовался этим:


>  or you can poll the
> Application.BaskgroundPrintingStatus property, which
> returns the count of Word print jobs outstanding - when
>
> it"s 0, quit.


Только вот пол-часа возился пока не заметил
Application.BaskgroundPrintingStatus
:-)))



Страницы: 1 вся ветка

Текущий архив: 2005.07.31;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.023 c
14-1120707744
X9
2005-07-07 07:42
2005.07.31
Бесплатный домен 2-го уровня


14-1120802921
ПЛОВ
2005-07-08 10:08
2005.07.31
Почему на материнских платах со встроеной видахой...


4-1116811498
boalse
2005-05-23 05:24
2005.07.31
Узнать серийный номер винта (не тома)....


14-1121195396
WondeRu
2005-07-12 23:09
2005.07.31
Свобода = Одиночество?


14-1120921148
Soft
2005-07-09 18:59
2005.07.31
Допускает ли Бог познание мира, а стало быть самого себя?