how can i change the default printer's layout ie from protait to landscape and then back again??? this has to be done without the dialog window.
Printable View
how can i change the default printer's layout ie from protait to landscape and then back again??? this has to be done without the dialog window.
Printer.Orientation = vbPRORLandscape
Are you doing it specifically for your own print run? If so it would be:VB Code:
Me.PrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True
jmcilhinney that's what i did orignally however i'm interfacing with a different application's api and there is a method that you simply send a document reference to the api's print method and it prints the document. however it doesn't have an option or method to allow me to change anything to do with the printer in the api.
so i was thinking that if i could programmatically change the default printer's orientation to landscape and then back to portrait after the printing is complete. however, if i use the code above the printer still prints in portrait. I'm assuming I would have to us some win api or change something in the registery
I'm certainly not sure but I'm thinking that you would have to use the Windows API. Everything I've seen in the Printing namespace seems geared towards using a PrintDocument.
that's what i figured, i'm searching for any additional info that i can
SetPrinter API - or if yopu want to use a wrapped up in .NET style way download the PrintQueueWatch code and use the PrinterInformation class...
Geez Merrion. What do you know about printing? ;) :p
i'm looking at the class but i'm not seeing how to change the layoutQuote:
Originally Posted by Merrion
i'm trying to use
VB Code:
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA"_ (ByVal pPrinterName As String, _ ByVal phPrinter As Integer, _ ByVal pDefault As PRINTER_DEFAULTS) As Integer
and i get an exception of
A call to PInvoke function 'PickTicketPrinter!PickTicketPrinter.PrinterSettingsWrapper::OpenPrinter' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
if i take out the alias i get the following
Unable to find an entry point named 'OpenPrinter' in DLL 'winspool.drv'.
what am i doing wrong?
Odd - what operating system are you using?
winxp
I have:-
VB Code:
<DllImport("winspool.drv", EntryPoint:="OpenPrinter", _ SetLastError:=True, CharSet:=CharSet.Ansi, _ ExactSpelling:=False, _ CallingConvention:=CallingConvention.StdCall)> _ Public Function OpenPrinter(<InAttribute()> ByVal pPrinterName As String, _ <OutAttribute()> ByRef phPrinter As Int32, _ <InAttribute(), MarshalAs(UnmanagedType.LPStruct)> ByVal pDefault As PRINTER_DEFAULTS _ ) As Boolean End Function <DllImport("winspool.drv", EntryPoint:="OpenPrinter", _ SetLastError:=True, CharSet:=CharSet.Ansi, _ ExactSpelling:=False, _ CallingConvention:=CallingConvention.StdCall)> _ Public Function OpenPrinter(<InAttribute()> ByVal pPrinterName As String, _ <OutAttribute()> ByRef phPrinter As Int32, _ <InAttribute()> ByVal pDefault As Int32 _ ) As Boolean End Function <DllImport("winspool.drv", EntryPoint:="OpenPrinter", _ SetLastError:=True, CharSet:=CharSet.Ansi, _ ExactSpelling:=False, _ CallingConvention:=CallingConvention.StdCall)> _ Public Function OpenPrinter(<InAttribute()> ByVal pPrinterName As String, _ <OutAttribute()> ByRef phPrinter As IntPtr, _ <InAttribute()> ByVal pDefault As PrinterDefaults _ ) As Boolean End Function <StructLayout(LayoutKind.Sequential)> _ Friend Class PrinterDefaults #Region "Public interface" Public DataType As String Public lpDevMode As IntPtr Public DesiredAccess As PrinterAccessRights #End Region End Class <FlagsAttribute()> _ Public Enum PrinterAccessRights ' READ_CONTROL - Allowed to read printer information READ_CONTROL = &H20000 ' WRITE_DAC - Allowed to write device access control info WRITE_DAC = &H40000 ' WRITE_OWNER - Allowed to change the object owner WRITE_OWNER = &H80000 ' SERVER_ACCESS_ADMINISTER SERVER_ACCESS_ADMINISTER = &H1 ' SERVER_ACCESS_ENUMERATE SERVER_ACCESS_ENUMERATE = &H2 ' PRINTER_ACCESS_ADMINISTER Allows administration of a printer PRINTER_ACCESS_ADMINISTER = &H4 ' PRINTER_ACCESS_USE Allows printer general use (printing, querying) PRINTER_ACCESS_USE = &H8 ' PRINTER_ALL_ACCESS Allows use and administration. PRINTER_ALL_ACCESS = &HF000C ' SERVER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE) SERVER_ALL_ACCESS = &HF0003 End Enum
Not really an answer but more of a question on same lines i think, Using the New PrintForm powerpack is there a way of using that to bring up the normal print dialogue then being able to change settings in there to print?
Quote:
Originally Posted by Merrion
Merrion i used this but the changes aren't permanent. once the code finishes the orientation is still portrait.
nope doesn't do it eitherQuote:
Originally Posted by max_carpenter