Hallo zusammen,
ich habe folgendes Problem. Ich möchte eine Excel-Datei öffnen, diese ausdrucken und wieder schließen. Klinkt sehr einfach
Ich habe dazu einen Agenten geschrieben, der dies tut - aber er funktioniert nur lokal. Serverseitig bleibt er immer bei dem PrintOut hängen mit der Fehlermeldung "%s" Fehler: 213. Wenn ich diesen Befehl allerdings in ein Excel-Makro übertrage und dort ausführe, funktioniert er auch einwandfrei. Ich poste mal den Quellcode, vielleicht hat ja jemand von euch eine Ahnung.
Dankeschön! - Gruß Andy
Code
Function SendFax(doc As notesdocument, file As String) As Boolean
Dim s As New notessession
Dim db As NotesDatabase
Dim profDoc As NotesDocument
Dim word As Variant
Dim logdoc As NotesDocument
Dim Workbook As Variant
Dim Sheet As Variant
sendfax = True
Set db=s.currentdatabase
Set profDoc=db.getProfileDocument("(Profil)")
Set userName = s.CreateName(s.UserName)
On Error Goto raus
'Open Excel & load Form
If Not file = "" Then
Set Excel = CreateObject("Excel.Application") 'Create Excel object
If Err = "208" Then
SendFax = False
Set logdoc = AgentLog(logdoc,"BuehlerBack - SendFax","Unable to start Excel !")
Exit Function
End If
If excel Is Nothing Then
SendFax = False
Set logdoc = AgentLog(logdoc,"BuehlerBack - SendFax","Unable to start Excel ! Error: "+Cstr(Err)+" - "+Error$(Err))
Exit Function
End If
Set workbook = Excel.workbooks.add(file) 'create new Workbook based on my template
Set Sheet = Workbook.ActiveSheet
If Err = "213" Then
SendFax = False
Excel.quit(wdDoNotSaveChanges)
Set logdoc = AgentLog(logdoc,"BuehlerBack - SendFax","Excel could not load File "+file+" ! - Print was canceld !")
Exit Function
End If
End If
Call sheet.printout(,,,,Cstr(profdoc.maFaxDruckername(0)))
Exit Function
raus:
'Außer bei "Kill File" - Fehler, immer Error Log !!!
If Not Cstr(Err) = "75" Then
SendFax = False
Set logdoc = AgentLog(logdoc,"BuehlerBack - SendFax","An Error occured in Line :"+Cstr(Erl)+" Error: "+Cstr(Err)+" - "+Error$(Err))
End If
Resume Next
End Function
Alles anzeigen