Private Declare 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 LongPrivate Declare Function PrinterProperties Lib "winspool.drv" (ByVal hwnd As _ Long, ByVal hPrinter As Long) As LongPrivate Declare Function SHInvokePrinterCommand Lib "shell32.dll" Alias _ "SHInvokePrinterCommandA" (ByVal hwnd As Long, _ ByVal uAction As enPrinterActions, ByVal Buffer1 As String, _ ByVal Buffer2 As String, ByVal Modal As Long) As LongPrivate Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _ (ByVal pPrinterName As String, phPrinter As Long, _ pDefault As PRINTER_DEFAULTS) As LongPrivate Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" _ (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, _ ByVal Command As Long) As LongPrivate Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _ (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, _ ByVal cbBuf As Long, pcbNeeded As Long) As LongPrivate Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal _ lpString1 As String, ByVal lpString2 As Any) As LongPrivate Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As _ Long) As Long' *** Constants for DEVMODE structurePrivate Const CCHDEVICENAME = 32Private Const CCHFORMNAME = 32' *** constants for DesiredAccess member of PRINTER_DEFAULTSPrivate Const STANDARD_RIGHTS_REQUIRED = &HF0000Private Const PRINTER_ACCESS_ADMINISTER = &H4Private Const PRINTER_ACCESS_USE = &H8Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _ PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)Private Type DEVMODE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Long dmDriverVersion As Long dmSize As Long dmDriverExtra As Long dmFields As Long dmOrientation As Long dmPageSize As Long dmPaperLength As Long dmPaperWidth As Long dmScale As Long dmCopies As Long dmDefaultSource As Long dmPrintQuality As Long dmColor As Long dmDuplex As Long dmYResolution As Long dmTToption As Long dmCollate As Long dmFormName As String * CCHFORMNAME dmLogPixels As Long dmBitsPerPel As Long dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long dmICMMethod As Long ' // Windows 95 only dmICMIntent As Long ' // Windows 95 only dmMediaType As Long ' // Windows 95 only dmDitherType As Long ' // Windows 95 only dmReserved1 As Long ' // Windows 95 only dmReserved2 As Long ' // Windows 95 onlyEnd TypePrivate Type PRINTER_DEFAULTS pDatatype As Long pDevMode As DEVMODE DesiredAccess As LongEnd TypePrivate Enum enPrinterActions PRINTACTION_OPEN = 0 PRINTACTION_PROPERTIES = 1 PRINTACTION_NETINSTALL = 2 PRINTACTION_NETINSTALLLINK = 3 PRINTACTION_TESTPAGE = 4 PRINTACTION_OPENNETPRN = 5 PRINTACTION_DOCUMENTDEFAULTS = 6 PRINTACTION_SERVERPROPERTIES = 7End Enum' Get the default printer Driver name' Example: Debug.Print GetDefaultDriverName()Private Function GetDefaultDriverName() As String Dim sTmp As String On Error Resume Next sTmp = Space$(1000) Call GetProfileString("windows", "Device", vbNullString, sTmp, 1000) sTmp = Replace(sTmp, Chr$(0), vbNullString) sTmp = Trim$(sTmp) If sTmp = vbNullString Then sTmp = Printer.DriverName Else sTmp = GetToken(sTmp, ",", 1) End If If sTmp = vbNullString Then sTmp = Printer.DriverName End If GetDefaultDriverName = sTmpEnd Function' This function returns the nToken sToken in a string' Example:' Debug.Print GetToken("This is a test.", " ", 2) ' => "is"Private Function GetToken(sSearchIn As String, sToken As String, _ nToken As Long) As String Dim nI As Long Dim nJ As Long Dim nK As Long If nToken '========================================' You can find more routines like this on www.vbdiamond.com,' a site devoted to VB developers'========================================