Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 29th, 2003, 09:21 PM
grwd grwd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 5 grwd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
OLE msWord Automation - How to open Print Dialog?

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)
Code:
...
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?
Comments on this post
Gran Roguismo agrees!

Reply With Quote
  #2  
Old October 29th, 2003, 11:08 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,589 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 26 m 52 sec
Reputation Power: 1001
Try something like this:
Code:
prntDlg := wrdApp.Dialogs.item(wdDialogFilePrint);
printDlg.Show;
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month
Looking for a perl job with kick-*** programmers in a well-known NASDAQ listed tech company with branches in the US and Europe? We're hiring. PM me for details. Requirements

Reply With Quote
  #3  
Old October 30th, 2003, 12:08 PM
grwd grwd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 5 grwd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question RE:RE:How to open Print Dialog?

In your answer:
Code:
prntDlg := 
wrdApp.Dialogs.item(wdDialogFilePrint);
printDlg.Show;


What is item refering to? (the Document?)
And what type of variable is it? (Varient?)

Reply With Quote
  #4  
Old November 1st, 2003, 07:52 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,589 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 26 m 52 sec
Reputation Power: 1001
item is an enumeration of the dialogs in the Word.Application object. See http://msdn.microsoft.com/library/d...alogmethods.asp for more.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > OLE msWord Automation - How to open Print Dialog?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT