Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you change the default printer?
I would like to from within Excel as an VBA instruction change the
name of the default printer, just as if I went to the Windows Control Panel and did it. Incorporating in my code either of the instructions Application.Dialogs(xlDialogPrint).Show or Application.Dialogs(xlDialogPrinterSetup).Show lets me change the printer for that job, but seems to leave the name of the default printer the same as before. Any suggestions, anyone? -- Dennis Eisen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you change the default printer?
"DennisE" wrote...
I would like to from within Excel as an VBA instruction change the name of the default printer, just as if I went to the Windows Control Panel and did it. Incorporating in my code either of the instructions Application.Dialogs(xlDialogPrint).Show or Application.Dialogs(xlDialogPrinterSetup).Show lets me change the printer for that job, but seems to leave the name of the default printer the same as before. Any suggestions, anyone? You can use VBA to change the name of the ActivePrinter. The macro recorder gives something like Application.ActivePrinter = "Generic / Text Only on FILE:" You could always put this in a BeforePrint event handler. The default printer, on the other hand, is a Windows-wide configuration setting. You may need to make a Windows API call to do this. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you change the default printer?
I assume you mean for Excel and not for all windows applications.
Look at help setting the ActivePrinter (turn on the macro recorder and perform the action manually - that will also be helpful). I believe that and what you have shown are what are offered internally to Excel and VBA. After that, you would probably need to use the Windows API. -- Regards, Tom Ogilvy DennisE wrote in message ... I would like to from within Excel as an VBA instruction change the name of the default printer, just as if I went to the Windows Control Panel and did it. Incorporating in my code either of the instructions Application.Dialogs(xlDialogPrint).Show or Application.Dialogs(xlDialogPrinterSetup).Show lets me change the printer for that job, but seems to leave the name of the default printer the same as before. Any suggestions, anyone? -- Dennis Eisen |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you change the default printer?
this shows how to use the Windows API in VB to do it. It would need to be
adapted to VBA. http://support.microsoft.com/default...b;en-us;266767 HOWTO: Set Which Printer Is the System Default Printer Another approach might be to take a picture of the useform, put it on a blank sheet and print the sheet. Following code was posted previously by Orlando Magalhaes Filho: In a general module put in these declarations/code: Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Public Const VK_SNAPSHOT = &H2C Sub Test() UserForm1.Show End Sub In the code module of the Userform: Private Sub CommandButton1_Click() keybd_event VK_SNAPSHOT, 0, 0, 0 Workbooks.Add Application.Wait Now + TimeValue("00:00:01") ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, _ DisplayAsIcon:=False ActiveSheet.Range("A1").Select ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Close False End Sub This takes a "picture" of the userform and pastes it on a sheet (adds a workbook with a sheet, prints, then closes the workbook without saving change). It then prints the picture on the sheet. Regards, Tom Ogilvy Tom Ogilvy wrote in message ... I assume you mean for Excel and not for all windows applications. Look at help setting the ActivePrinter (turn on the macro recorder and perform the action manually - that will also be helpful). I believe that and what you have shown are what are offered internally to Excel and VBA. After that, you would probably need to use the Windows API. -- Regards, Tom Ogilvy DennisE wrote in message ... I would like to from within Excel as an VBA instruction change the name of the default printer, just as if I went to the Windows Control Panel and did it. Incorporating in my code either of the instructions Application.Dialogs(xlDialogPrint).Show or Application.Dialogs(xlDialogPrinterSetup).Show lets me change the printer for that job, but seems to leave the name of the default printer the same as before. Any suggestions, anyone? -- Dennis Eisen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Default settings for my printer in Excel change when Import workbo | Excel Discussion (Misc queries) | |||
Default Printer | Excel Discussion (Misc queries) | |||
members on my network printer not able to print to default printer | Excel Discussion (Misc queries) | |||
How do I change default printer settings | Setting up and Configuration of Excel | |||
excel macro to automatically change default printer | Excel Discussion (Misc queries) |