Hi Jack,
No, the ActiveX component does not have this function.
But, good news: the code given in the Sample Access VBA programs shows you how to do exactly that because older Access versions do not have a built-in VBA command for that.
Here is a summary: simply use the following two functions that get and set the default printer:
' GetDefaultPrinter Function (Only required in Access) Private Function GetDefaultPrinter() As String GetDefaultPrinter = Space$(1024) GetDefaultPrinter = Trim$(Left$(GetDefaultPrinter, GetProfileString("windows", "device", "", GetDefaultPrinter, 1024))) End Function
' SetDefaultPrinter Function Private Function SetDefaultPrinter(PrinterName_DriverName_PrinterPort As String) As Boolean WriteProfileString "windows", "device", PrinterName_DriverName_PrinterPort SetDefaultPrinter = CBool(SendMessageByString(&HFFFF&, &H1A, 0&, "windows")) End Function
You will need to declare the following Windows API functions:
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long 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 Long Private Declare Function SendMessageByString Lib "user32" Alias
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As
Long, ByVal lParam As String) As Long
Again, the Access demo code will show you how to call the function to set the printer (it's one string with the three parameters separated by commas).
I hope that helps,
Michel
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|