Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 88
Default Help with Printing Userforms

Hi All,
I'm having diffilculty in Printing my Userforms to a specific
printer.

The Code I've used previously to print sections of a worksheet is as follows:

Sub CmdPrint()
Dim Printb as Boolean

ActiveSheet.PageSetup.PrintArea = "$HG$7:$HM$16"
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then ' Print only if OK Button is pressed
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd

Elseif Printb = False Then ' Cancells Print operation
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd
End sub

When printing a userform I tried to use the code:
Sub PrintReports1

Dim Printb as Boolean
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then
DailyReports1.PrintForm
Elseif Printb = False Then ' Cancells Print operation
ActiveWorkbook.Protect Password:=Passwd
End if

But this seems to send the data to a different Printer than requested, but
it seems to be alway the same one, but this is an old Printer that no longer
exists. I know i can uninstall this printer but this in it'self wouldn't
solve the problem.

Can anyone advise me on where I've gone wrong with the code, I need to use
the xlDialogPrinterSetup due to the end Users PC's having different Printer
Configurations setups.

Regards
Lee
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Help with Printing Userforms

I don't have a guess why things are going wrong--you are positive that the users
are changing printers, right?

But after you display the dialog, you could check the name of the printer and
see it's the bad one. If it is, then give a warning and don't print.

But this doesn't really solve your problem.

leerem wrote:

Hi All,
I'm having diffilculty in Printing my Userforms to a specific
printer.

The Code I've used previously to print sections of a worksheet is as follows:

Sub CmdPrint()
Dim Printb as Boolean

ActiveSheet.PageSetup.PrintArea = "$HG$7:$HM$16"
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then ' Print only if OK Button is pressed
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd

Elseif Printb = False Then ' Cancells Print operation
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd
End sub

When printing a userform I tried to use the code:
Sub PrintReports1

Dim Printb as Boolean
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then
DailyReports1.PrintForm
Elseif Printb = False Then ' Cancells Print operation
ActiveWorkbook.Protect Password:=Passwd
End if

But this seems to send the data to a different Printer than requested, but
it seems to be alway the same one, but this is an old Printer that no longer
exists. I know i can uninstall this printer but this in it'self wouldn't
solve the problem.

Can anyone advise me on where I've gone wrong with the code, I need to use
the xlDialogPrinterSetup due to the end Users PC's having different Printer
Configurations setups.

Regards
Lee


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 88
Default Help with Printing Userforms


Hi Dave,
Many thanks for your reply..

I've done as you suggested in trying to establish which printer has been
selected. eg by hovering over the 'xlDialogPrinterSet' which gives me a
result of 9, however when i then change the selected printer it still gives
me a result of 9.

Any ideas


"Dave Peterson" wrote:

I don't have a guess why things are going wrong--you are positive that the users
are changing printers, right?

But after you display the dialog, you could check the name of the printer and
see it's the bad one. If it is, then give a warning and don't print.

But this doesn't really solve your problem.

leerem wrote:

Hi All,
I'm having diffilculty in Printing my Userforms to a specific
printer.

The Code I've used previously to print sections of a worksheet is as follows:

Sub CmdPrint()
Dim Printb as Boolean

ActiveSheet.PageSetup.PrintArea = "$HG$7:$HM$16"
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then ' Print only if OK Button is pressed
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd

Elseif Printb = False Then ' Cancells Print operation
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd
End sub

When printing a userform I tried to use the code:
Sub PrintReports1

Dim Printb as Boolean
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then
DailyReports1.PrintForm
Elseif Printb = False Then ' Cancells Print operation
ActiveWorkbook.Protect Password:=Passwd
End if

But this seems to send the data to a different Printer than requested, but
it seems to be alway the same one, but this is an old Printer that no longer
exists. I know i can uninstall this printer but this in it'self wouldn't
solve the problem.

Can anyone advise me on where I've gone wrong with the code, I need to use
the xlDialogPrinterSetup due to the end Users PC's having different Printer
Configurations setups.

Regards
Lee


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Help with Printing Userforms

First, I'm not sure why you're stopping the user from printing if he/she hits
the cancel button on that dialog. If the correct printer is already active,
then they could just hit Cancel to dismiss that dialog.

I think you'd be better off just asking them:

Dim Resp as long
resp = Inputbox(Prompt:="You sure you want to print?", buttons:=vbyesno)
if resp = vbno then
exit sub
end if

Application.Dialogs(xlDialogPrinterSetup).Show

'now check for the bad printer name

if Application.ActivePrinter = "the bad printer name here" then
msgbox "That printer is not available!"
exit sub
end if

Untested, uncompiled. Watch for typos.

======
If the bad printer's name can vary, maybe you could look at the left most x
number of characters:

if lcase(left(application.activeprinter, 12)) = "123412341234" then
msgbox ...




leerem wrote:

Hi Dave,
Many thanks for your reply..

I've done as you suggested in trying to establish which printer has been
selected. eg by hovering over the 'xlDialogPrinterSet' which gives me a
result of 9, however when i then change the selected printer it still gives
me a result of 9.

Any ideas

"Dave Peterson" wrote:

I don't have a guess why things are going wrong--you are positive that the users
are changing printers, right?

But after you display the dialog, you could check the name of the printer and
see it's the bad one. If it is, then give a warning and don't print.

But this doesn't really solve your problem.

leerem wrote:

Hi All,
I'm having diffilculty in Printing my Userforms to a specific
printer.

The Code I've used previously to print sections of a worksheet is as follows:

Sub CmdPrint()
Dim Printb as Boolean

ActiveSheet.PageSetup.PrintArea = "$HG$7:$HM$16"
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then ' Print only if OK Button is pressed
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd

Elseif Printb = False Then ' Cancells Print operation
Sheets("calculations").Visible = False
ActiveWorkbook.Protect Password:=Passwd
End sub

When printing a userform I tried to use the code:
Sub PrintReports1

Dim Printb as Boolean
Printb = Application.Dialogs(xlDialogPrinterSetup).Show
If Printb = True Then
DailyReports1.PrintForm
Elseif Printb = False Then ' Cancells Print operation
ActiveWorkbook.Protect Password:=Passwd
End if

But this seems to send the data to a different Printer than requested, but
it seems to be alway the same one, but this is an old Printer that no longer
exists. I know i can uninstall this printer but this in it'self wouldn't
solve the problem.

Can anyone advise me on where I've gone wrong with the code, I need to use
the xlDialogPrinterSetup due to the end Users PC's having different Printer
Configurations setups.

Regards
Lee


--

Dave Peterson


--

Dave Peterson
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
Printing UserForms leerem Excel Discussion (Misc queries) 1 November 20th 08 10:35 PM
Help with Userforms Panagiotis Marantos Excel Discussion (Misc queries) 2 July 25th 06 04:26 PM
I need some help with userforms T.c.Goosen1977 Charts and Charting in Excel 0 June 30th 06 09:29 AM
I need some help with userforms T.c.Goosen1977 Excel Discussion (Misc queries) 0 June 30th 06 09:27 AM
UserForms bennyob Excel Discussion (Misc queries) 4 November 7th 05 01:58 PM


All times are GMT +1. The time now is 09:23 AM.

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

About Us

"It's about Microsoft Excel"