![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com