BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Print / PrintPreview Excel file without opening Excel

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Eduardo A. Salgado
Guest





PostPosted: Sat Jan 08, 2005 5:32 pm    Post subject: Print / PrintPreview Excel file without opening Excel Reply with quote



I cannot find how to take an excel file (say C:Test.XLS) and having it
go to Print or Print Preview.

What I am really trying to do is send a file to the printer with "shrink
to fit" to one page wide.

I've even tried
try
xls := CreateOleObject('Excel.Application');
try
xls.WorkBooks.Open('c:Excel ExportRCCompara.XLS');
xls.ActiveWorkBook.PrintOut(Copies := 2, Collate := True,
Preview := True); // excel hangs and remains in memory
xls.Quit;
except;
xls.Quit;
xls := UnAssigned;
end;
finally
xls := UnAssigned;
end;



- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.
Back to top
Mike Shkolnik
Guest





PostPosted: Sat Jan 08, 2005 6:41 pm    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote



Your code is correct for foreground printing. But most MS Excel edition have
the background printing by default - so you must wait until printing is
finished and only after that to call the xls.Quit

--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com

"Eduardo A. Salgado" <eas (AT) onedomain (DOT) com> wrote

Quote:
I cannot find how to take an excel file (say C:Test.XLS) and having it
go to Print or Print Preview.

What I am really trying to do is send a file to the printer with "shrink
to fit" to one page wide.

I've even tried
try
xls := CreateOleObject('Excel.Application');
try
xls.WorkBooks.Open('c:Excel ExportRCCompara.XLS');
xls.ActiveWorkBook.PrintOut(Copies := 2, Collate := True,
Preview := True); // excel hangs and remains in memory
xls.Quit;
except;
xls.Quit;
xls := UnAssigned;
end;
finally
xls := UnAssigned;
end;



- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.



Back to top
Eduardo A. Salgado
Guest





PostPosted: Mon Jan 10, 2005 2:22 pm    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote



I see that and have tried to create the ole object in the form create
and do the quit and free it in the close yet I never get to see the
Print dialog or PrintPreview come up.

So, what is the code to just call up the Print Dialog? Or Print to Fit
in one page wide and not open Excel?

Thanks!


- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.



Mike Shkolnik wrote:
Quote:
Your code is correct for foreground printing. But most MS Excel edition have
the background printing by default - so you must wait until printing is
finished and only after that to call the xls.Quit


Back to top
Mike Shkolnik
Guest





PostPosted: Mon Jan 10, 2005 2:47 pm    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote

- to show the dialog:
Word.Dialogs.Item(wdDialogFilePrintSetup).Show(EmptyParam);

- to disable the background printing
Word.Options.PrintBackground := False;

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Eduardo A. Salgado" <eas (AT) onedomain (DOT) com> wrote

Quote:
I see that and have tried to create the ole object in the form create
and do the quit and free it in the close yet I never get to see the
Print dialog or PrintPreview come up.

So, what is the code to just call up the Print Dialog? Or Print to Fit
in one page wide and not open Excel?

Thanks!


- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.



Mike Shkolnik wrote:
Your code is correct for foreground printing. But most MS Excel edition
have
the background printing by default - so you must wait until printing is
finished and only after that to call the xls.Quit




Back to top
Eduardo A. Salgado
Guest





PostPosted: Mon Jan 10, 2005 7:54 pm    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote

Mike,

Thanks for the info but I keep getting "Member not Found". Did I skip a
step?

xls.Dialogs.Item(xlDialogPrintPreview).Show(EmptyParam);

- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.


Mike Shkolnik wrote:
Quote:
- to show the dialog:
Word.Dialogs.Item(wdDialogFilePrintSetup).Show(EmptyParam);

- to disable the background printing
Word.Options.PrintBackground := False;

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

Back to top
Mike Shkolnik
Guest





PostPosted: Tue Jan 11, 2005 10:19 am    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote

1. xls.ActiveWindow.PrintPreview
or
xls.ActiveSheet.PrintPreview
or
2. for late binding (xls := CreateOLEObject('Excel.Application') the next
works for me:
xls.Dialogs[xlDialogPrintPreview].Show

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Eduardo A. Salgado" <eas (AT) onedomain (DOT) com> wrote

Quote:
Mike,

Thanks for the info but I keep getting "Member not Found". Did I skip a
step?

xls.Dialogs.Item(xlDialogPrintPreview).Show(EmptyParam);

- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.


Mike Shkolnik wrote:
- to show the dialog:
Word.Dialogs.Item(wdDialogFilePrintSetup).Show(EmptyParam);

- to disable the background printing
Word.Options.PrintBackground := False;

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com



Back to top
Eduardo A. Salgado
Guest





PostPosted: Tue Jan 11, 2005 2:04 pm    Post subject: Re: Print / PrintPreview Excel file without opening Excel Reply with quote

Thanks again for the knowledge.

- Eduardo
It's more important to know *what not* to do
than to know *what* to do.
-- Michael Dell

Eminent Domain Software
"Custom Software Development For Your Domain"

Makers of EDSSpell, EDSPrint, EDSZipCodes and
XSpell, the IDE Expert.


Mike Shkolnik wrote:
Quote:
1. xls.ActiveWindow.PrintPreview
or
xls.ActiveSheet.PrintPreview
or
2. for late binding (xls := CreateOLEObject('Excel.Application') the next
works for me:
xls.Dialogs[xlDialogPrintPreview].Show

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.