Hallo Forum
Ich suche nach einer Möglichkeit, aus LotusScript herraus Mail + Anhang zu drucken. Soweit ist es mir auch schon gelungen, nur das als Drucker immer der Standarddrucker benutzer wird. An dieser Stelle möchte ich eingreifen und einen bestimmten Drucker ansprechen. Ich habe schon etwas recherchiert und folgendes Script aus einen Post von Eknori gefunden und benutzt:
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
Sub [whatever]
Dim WshNetwork As Variant
Dim WshPrinters As Variant
Dim pArray() As String
Dim strBuffer As String * 254
Dim iRetValue As Long
Dim DefaultPrinter As String
Dim pCount As Integer
Dim n As Integer
Dim PrinterPath As Variant
' Retreive current default printer information
iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
DefaultPrinter$ = Left(strBuffer, Instr(strBuffer, ",") - 1)
Print "Current default printer is " & DefaultPrinter$
Set WshNetwork = CreateObject("WScript.Network")
Set WshPrinters = WshNetwork.EnumPrinterConnections()
'count the connected printers
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then pCount%=pCount%+1
Next
'collect the names of the connected printers
Redim pArray(pCount%-1) As String
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then
pArray(pCount%) = wshPrinters(n)
pCount%=pCount%+1
End If
Next
PrinterPath = ws.Prompt(4,"Select Printer","Choose a printer from the following list:","",pArray)
If Cstr(PrinterPath)="" Then Exit Sub
WshNetwork.SetDefaultPrinter Cstr(PrinterPath)
Print "Default printer is now " & Cstr(PrinterPath)
'*****************************************
' Print what you need to print here
'*****************************************
WshNetwork.SetDefaultPrinter DefaultPrinter$
Print "Default printer restored to " & DefaultPrinter$
Set WshNetwork = Nothing
Set WshPrinters = Nothing
End Sub
Leider schaffe ich es nicht, dieses Script zum laufen zu bringen.
In der Zeile
PrinterPath = ws.Prompt(4,"Select Printer","Choose a printer from the following list:","",pArray)
bekomme ich immer die Fehlermeldung
Variant does not contain an object
Weiß jemand was dort falsch ist, oder was ich falsch configuriert habe?
Viele Grüße Christian