how to show ms-word's print dialog programatically ?

how to show ms-word's print dialog programatically ?

Post by Imra » Thu, 24 Mar 2005 19:03:12


hi,
I want to show the ms-word's print dialog programatically (which ms-word
shows on ctrl-P) using the oleautomation object
Does anybody know the right commant for it.
The macro for that is not being recorded in ms-word.
I am using Delphi-5 with Word-2000.

regards,
 
 
 

how to show ms-word's print dialog programatically ?

Post by George Bir » Thu, 24 Mar 2005 20:49:06

maybe the print-related methods take an optional boolean parameter to show
that dialog?

use the "Object Browser" at the VBA editor (not at the MS script editor).
Open VBA from under the Tools/Macro menu or show the VBA toolbar by
rightclicking any toolbar and checking the respective option, then click on
the appropriate toolbar button to show VBA editor. At Object Browser you can
set it to search only at Word typelibrary and then enter Print. Select a
method to see its definition/parameters at the bottom of the Object Browser
window

btw. else you could use the Delphi Type Library Editor I think or even
OleView tool and open the Word typelibrary in it to see the help strings

there is also some free tool arround (can check my favorites if you can't
find it) to make docs out of a typelibrary. I think it includes such
helpstrings at the generated docs

 
 
 

how to show ms-word's print dialog programatically ?

Post by Bob Zirbe » Fri, 25 Mar 2005 09:12:45

Imran

This is the code I use to print Word documents programmatically. You need a
print dialog on your form for it to work. Hope it helps.

Regards

Bob

WordApplication.Connect;
WordApplication.Application.Visible := False;
WordApplication.Documents.Open(ovFileName, emptyParam, emptyParam,
emptyParam, emptyParam, emptyParam, emptyParam, emptyParam,
emptyParam, emptyParam, emptyParam, emptyParam);
PrintDialog.MaxPage :=
WordApplication.Selection.Information[wdActiveEndPageNumber];
if PrintDialog.Execute then begin
ovNumCopies := PrintDialog.Copies;
if PrintDialog.PrintRange = prAllPages then begin
ovRange := wdPrintAllDocument;
WordApplication.ActiveDocument.PrintOut(emptyParam,
emptyParam, ovRange,
emptyParam, emptyParam, emptyParam, emptyParam, ovNumCopies,
emptyParam,
emptyParam, emptyParam, emptyParam, ovFileName, emptyParam,
emptyParam,
emptyParam, emptyParam, emptyParam);
end
else begin
ovRange := wdPrintFromTo;
ovFromPage := IntToStr(PrintDialog.FromPage);
ovToPage := IntToStr(PrintDialog.ToPage);
WordApplication.ActiveDocument.PrintOut(emptyParam,
emptyParam, ovRange,
emptyParam, ovFromPage, ovToPage, emptyParam, emptyParam,
ovNumCopies,
emptyParam, emptyParam, emptyParam, emptyParam, ovFileName,
emptyParam,
emptyParam, emptyParam, emptyParam);
end;
Sleep(1000 + (1000 * PrintDialog.MaxPage));
end;
WordApplication.ActiveDocument.Close(olewdDoNotSaveChanges,
emptyParam, emptyParam);
WordApplication.Disconnect;
 
 
 

how to show ms-word's print dialog programatically ?

Post by Imra » Wed, 30 Mar 2005 20:19:29

Thanx George, though it didn't solve my problem but now i know how to use
Object Browser stuff.

Thanx Bob, It indeed solved my problem but i would really liked to have
word's own print dialog that i am still unable to get.
 
 
 

how to show ms-word's print dialog programatically ?

Post by Team » Thu, 31 Mar 2005 23:39:24

<<Imran:
i would really liked to have word's own print dialog that i
am still unable to get.

var
Dlg: olevariant;
begin
Dlg := Word.Dialogs.Item(wdDialogFilePrint);
Dlg.Show(EmptyParam);

--
Deborah Pate (TeamB) http://www.yqcomputer.com/

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.yqcomputer.com/
 
 
 

how to show ms-word's print dialog programatically ?

Post by George Bir » Fri, 01 Apr 2005 03:37:16

> Thanx Bob, It indeed solved my problem but i would really liked to have

see older newsgroup message on how to get the window handle of Word, then
post a (fake) CTRL+P keypress event to it ;o)

-----
George Birbilis ( XXXX@XXXXX.COM )
Microsoft Most Valuable Professional
MVP J# for 2004 & 2005
http://www.yqcomputer.com/
--------------