title image


Smiley Re: Druckerwechsel per VBA
Das geht über die API:Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" _ (ByVal lpszSection As String, ByVal lpszKeyName As String, _ ByVal lpszString As String) As LongDeclare 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 LongDeclare Function SendMessage Lib "User32" Alias "SendMessageA" _ (ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As LongPublic Const HWND_BROADCAST = &HFFFF&Public Const WM_WININICHANGE = &H1APublic Function SetDefaultPrinter(PrName As String)' Parameter: Druckername' Rückgabewert: Erfolg der AktionDim Buffer As String, RW, Tmp As StringOn Error GoTo Er Buffer = String(255, 0) RW = GetProfileString(ByVal "devices", ByVal PrName, ByVal "", Buffer, Len(Buffer)) If RW SetDefaultPrinter = False Exit Function Else Tmp = PrName & "," & Mid(Buffer, 1, RW) End If' Standarddrucker setzen RW = WriteProfileString(ByVal "Windows", ByVal "Device", ByVal Tmp) If RW 1 Then SetDefaultPrinter = False Exit Function End If' und mitteilen, daß sich die WIN.INI geändert hat RW = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0&, 0&) SetDefaultPrinter = TrueEx: Exit FunctionEr: MsgBox "SetDefaultPrinter: " & Err.Description SetDefaultPrinter = False Resume ExEnd FunctionReinhard


Gruß aus dem Norden
Reinhard


Bitte immer die Access-Version angeben!
DB-Wiki


Wie man Fragen richtig stellt

YaccessAccess-FAQUnd ansonsten: Wikipedia




geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: