-
Re: Printout3 to print to default WINDOWS printer
Michael Dekoning Sep 5, 2016 12:33 PM (in response to Eimantas Palevicius)SolidWorks uses the Windows printing settings for this. In .Net you can use System.Drawing.Printing.PrinterSettings.InstalledPrinters() to get the printers for the computer then iterate through them and use the IsDefaultPrinter property to find it.
-
Re: Printout3 to print to default WINDOWS printer
Eimantas Palevicius Sep 6, 2016 7:12 AM (in response to Michael Dekoning)well, i am using VBA, so this does not work. Anyway, thanks for response.
-
Re: Printout3 to print to default WINDOWS printer
Ivana Kolin Sep 6, 2016 9:20 AM (in response to Eimantas Palevicius)I can't try it, because I have only tablet now, but this should work.
http://www.andreavb.com/tip070005.html
or maybe even Printer.DeviceName
-
Re: Printout3 to print to default WINDOWS printer
Simon Turner Sep 6, 2016 10:01 AM (in response to Ivana Kolin)Edited to make it work for 64 bit VBA:
Declare PtrSafe Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Sub main()
Debug.Print GetDefaultPrinter
End Sub
Private Function GetDefaultPrinter() As String
Dim strBuffer As String * 254
Dim iRetValue As Long
Dim strDefaultPrinterInfo As String
Dim tblDefaultPrinterInfo() As String
iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
strDefaultPrinterInfo = Left(strBuffer, InStr(strBuffer, Chr(0)) - 1)
tblDefaultPrinterInfo = Split(strDefaultPrinterInfo, ",")
GetDefaultPrinter = tblDefaultPrinterInfo(0)
End Function
-
Re: Printout3 to print to default WINDOWS printer
Ivana Kolin Sep 6, 2016 10:02 AM (in response to Simon Turner)thank you
-
Re: Printout3 to print to default WINDOWS printer
Eimantas Palevicius Sep 7, 2016 9:13 AM (in response to Simon Turner)Thank you. Everything works fine now.
-
-
-
-