Advertisement
Advertisement
| 01.29.2008 at 06:27AM PST, ID: 23119266 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: |
Private Declare Function SetDefaultPrinter Lib "winspool.drv" _ Alias "SetDefaultPrinterA" _ (ByVal pszPrinter As String) As Long Private Declare Function GetDefaultPrinter Lib "winspool.drv" Alias "GetDefaultPrinterA" (ByVal sPrinterName As String, lPrinterNameBufferSize As Long) As Long Dim DefPrinter As String, sLen As Long, hResult As Long Private Sub Workbook_Open() DefPrinter = Space$(255) sLen = 255 hResult = GetDefaultPrinter(ByVal DefPrinter, sLen) If hResult <> 0 Then DefPrinter = Left(DefPrinter, sLen - 1) MsgBox DefPrinter & sLen SetDefaultPrinter "\\server\printername" 'ThisWorkbook.ActiveSheet.PrintOut Copies:=1, Collate:=True 'ActiveWorkbook.Save 'Application.Quit End Sub |