DelphiSoure.comDelphiSoure.com
  Welcome Guest [Login] [Register] [Add/Edit/Delete Resources] [Link Us!] 102 Users Online, September 10, 2010 



Main Menu
   Top 50 Downloads
   Components
   News
   Online Forum
   Tips and Hints
   News Archive
   Gazette Archive
   Links
   Delphi Books
   Advertising
   About DelphiSource

 
Topic: OLE msWord Automation - How to open Print Dialog?
Name: grwd
Body:
In my D5 Application - When I click on a button I can start an instance of MS Word, open a document populate it with text, save it, print it to the default printer and close it..

But, how might I allow the user to access the MSWord FilePrint Dialog to select the printer to print to prior to it printing? Thank you in advance.
Below is the code I am currently using: (uses : comobj)
...
if sendViaValue = 'Print' then // ***begin print section***
begin
wrdApp := CreateOleObject('Word.Application');
wrdDoc := wrdApp.Documents.Open('Letterhead.doc');
wrdDoc.Select;
wrdSelection := wrdApp.Selection;
wrdApp.Selection.GoTo(wdGotoLine,wdGoToLast);
// Enter the date
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphRight;
wrdSelection.InsertDateTime('dddd, MMMM yyyy',False);
InsertLines(1);
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphLeft;
// Enter Address
wrdSelection.TypeText(ccName);
wrdSelection.TypeParagraph;
wrdSelection.TypeText(ccStreet);
wrdSelection.TypeParagraph;
if ccSuburb <> '' then
begin
wrdSelection.TypeText(ccSuburb);
wrdSelection.TypeParagraph;
end;
wrdSelection.TypeText(ccCityStateZip);
if (ccCountry <> '') and (ccCountry <> 'United States') then
begin
wrdSelection.TypeParagraph;
wrdSelection.TypeText(ccCountry);
end;
InsertLines(2);

wrdSelection.TypeText('Dear ' + ccFirst + ',');
wrdSelection.TypeParagraph;

InsertLines(1);

wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphJustify;
// Add Body Text
strToAdd := Clipboard.AsText;
wrdSelection.TypeText(strToAdd);
InsertLines(2);
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphLeft;
// Add salutation and signature
strToAdd := 'God loves you and we love you,' + Chr(13) +
'TGM Prayer Ministry';
wrdSelection.TypeText(strToAdd);
// Need to allow user to select Printer here.
wrdDoc.PrintOut;
wrdDoc.Saved := False;
wrdDoc.Close(False);
ShowMessage('Letter Sent to Printer');
end // *******end print section*******
...
Tim
tim@tgm.org

PS:
This msWord macro works inside of msWord:

Dialogs(wdDialogFilePrint).Show

Now how would I get this to work in my Delphi app?


Reply to this Topic
Sponsored Links

Advertise Here!

Video component for Delphi/C++Builder
AVI and ASF recording, compression on-the-fly or after recording, live network streaming, media player, DV timecode, DV date/time, DV camcorder control, motion detection, frame capture, frame overlay, TV tuning, videos built from set of images, deinterlacing, video rotation, brightness/contrast, dual display, and more...
[Visit Sponsor]

CoolDev.Com - Award winning Delphi components, CD/DVD toolkits, consulting and offshore development services.
[Visit Sponsor]

Datastead - VCL components for web and multimedia applications.
[Visit Sponsor]


Search DelphiSource.com
  

 
 Top 10 Downloads
 • [12447] ExDBGrid Component Suite
 • [12373] abfLabels
 • [9932] Storage library v2.72
 • [9841] Data Navigator
 • [8999] Audio Tools Library 1.3
 • [6951] Monster FTP
 • [6690] Peer to Peer Component Suite
 • [6370] TIAgaloLED
 • [6366] TAudioMixer
 • [5296] abfComControls

 Featured Book

More Books...
© Copyright DelphiSource 1998 - 2002
Contact Us: delphisource@delphisource.com