Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print dialog - force it to show up?

Hi there,

I have a feeling the answer to this is going to be "not possible", but
I figured it couldn't hurt to ask.

I have a multi-page Excel workbook. Each spreadsheet in the workbook
has a print CommandButton I've put at the bottom, plus of course the
print and print preview buttons on the Excel toolbar.

Recently I had to add an item to each sheet where some text in the
footer is created on the fly at printout, but only on the first page if
the printout of the worksheet is multiple pages. To accomplish that I
put code behind the print CommandButtons, and in the
Workbook_BeforePrint sub in ThisWorkbook, so it fires for both my print
button and the Excel toolbar buttons.

To avoid having spreadsheets print twice the code in
Workbook_BeforePrint includes a "Cancel=True" at the end, and looks
like this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
[Set up LeftFooter]
ActiveWindow.SelectedSheets.Printout From:=1, To:=1, Copies:=1
[Clear LeftFooter]
ActiveWindow.SelectedSheets.Printout From:=2, Copies:=1
Application.EnableEvents = True
Cancel = True
End Sub

However, one thing I neglected to think of is that with this code in
place, if the user selects File-Print, the spreadsheet just prints as
though the user had clicked the Excel toolbar print button, the print
dialog box does not come up.

It's not a critical thing as there are only a couple of the 50+ users
who regularly use the print dialog to change printers, but if there's a
way to actually bring up the print dialog when the user does a
File-Print that would be great.

Any thoughts?

Thanks!

Matt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print dialog - force it to show up?

application.Dialogs(xlDialogPrint).Show

Will show the print dialog, but its the real thing. When you click print,
it prints.

If you just want to select a printer you might use


application.Dialogs(xlDialogPrinterSetup).Show

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Hi there,

I have a feeling the answer to this is going to be "not possible", but
I figured it couldn't hurt to ask.

I have a multi-page Excel workbook. Each spreadsheet in the workbook
has a print CommandButton I've put at the bottom, plus of course the
print and print preview buttons on the Excel toolbar.

Recently I had to add an item to each sheet where some text in the
footer is created on the fly at printout, but only on the first page if
the printout of the worksheet is multiple pages. To accomplish that I
put code behind the print CommandButtons, and in the
Workbook_BeforePrint sub in ThisWorkbook, so it fires for both my print
button and the Excel toolbar buttons.

To avoid having spreadsheets print twice the code in
Workbook_BeforePrint includes a "Cancel=True" at the end, and looks
like this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
[Set up LeftFooter]
ActiveWindow.SelectedSheets.Printout From:=1, To:=1, Copies:=1
[Clear LeftFooter]
ActiveWindow.SelectedSheets.Printout From:=2, Copies:=1
Application.EnableEvents = True
Cancel = True
End Sub

However, one thing I neglected to think of is that with this code in
place, if the user selects File-Print, the spreadsheet just prints as
though the user had clicked the Excel toolbar print button, the print
dialog box does not come up.

It's not a critical thing as there are only a couple of the 50+ users
who regularly use the print dialog to change printers, but if there's a
way to actually bring up the print dialog when the user does a
File-Print that would be great.

Any thoughts?

Thanks!

Matt



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print dialog - force it to show up?


Just created a macro in the ThisWorkbook module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
msgbox "Hello world"
End Sub

and it fires just before I choose File|Print or press the PrintPrevie
button.

So I wouldn't understand why yours doesn't work.
Oh, I'm using XL2002

With kind regards,
Ton Teun

--
Ton
-----------------------------------------------------------------------
TonT's Profile: http://www.officehelp.in/member.php?userid=4
View this thread: http://www.officehelp.in/showthread.php?t=64673
Visit - http://www.officehelp.in | http://www.officehelp.in/index/index.php

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print dialog - force it to show up?

Thanks Tom, I'll give that a shot.

Is there any way for the code in Workbook_BeforePrint to recognize
whether it's being called from the print or print preview button or a
File-Print call so I can try to fire the code to show the print dialog
only when the user has gone through File-Print?

Thanks!

Matt

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print dialog - force it to show up?

Beforeprint fires before the dialog is displayed and you are using cancel,
so it should not display on its own. It seems to me the only time you
wouldn't want to show it is if the print button is clicked. However, even
if you put it up then, it would only be a minor annoyance I would think.

Now print preview is probably a problem. I don't know of a way to
differentiate. Perhaps you could again annoy your users by asking.



--
Regards,
Tom Ogilvy



wrote in message
ups.com...
Thanks Tom, I'll give that a shot.

Is there any way for the code in Workbook_BeforePrint to recognize
whether it's being called from the print or print preview button or a
File-Print call so I can try to fire the code to show the print dialog
only when the user has gone through File-Print?

Thanks!

Matt





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print dialog - force it to show up?

I'll have to decide if the print dialog is important enough to justify
the time to play around with the code to make it work. After
overcoming the problems of having the footer only on page 1 of
multipage printouts and preventing sheets from printing twice it might
not be worth the time to try and make another wrinkle work!

Thanks again for the input, Tom... Much appreciated!

Matt

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Force date cell to show [blank] if end of month lisa110rry Excel Discussion (Misc queries) 2 January 6th 07 01:33 PM
Force function to show positive or negative number? smoore Excel Worksheet Functions 3 March 3rd 06 08:34 PM
How do I force Excel to show filter totals in the Status bar? spider Excel Worksheet Functions 2 January 24th 06 02:29 PM
Force *relative* path in Insert Hyperlink dialog Mark Tangard[_3_] Excel Programming 3 January 17th 05 02:48 PM
Macro to Force Response in Dialog Box JenReyn Excel Programming 1 January 10th 04 01:12 AM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"