Autor Thema: Problem mit Script: Drucken markierter Dokumente (nur erste Seite)  (Gelesen 3850 mal)

Offline skrueger

  • Frischling
  • *
  • Beiträge: 11
Hi !
Ich habe ein Script, das alle in einer Ansicht markierten Dokumente drucken soll. Bei den Dokumenten soll dann nur die 1. Seite gedruckt werden.
Mein Problem ist: wenn ich 3 Dokumente in einer Ansicht markiere und dann drucke, wird das erste markierte Dokument 3x gedruckt.
(auch nur die 1. Seite, das ist also i.O.)
Aber warum druckt er die anderen 2 markierten Dokus nicht ?  :-:


Sub Click(Source As Button)
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim workspace As New NotesUIWorkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim uiview As NotesUIView
   
   Set db = session.CurrentDatabase
   Set uiview = workspace.CurrentView
   Set collection = db.unProcesseddocuments
   
   Set doc= collection.GetFirstDocument
   
   Do Until doc Is Nothing
      
      Call uiview.SelectDocument(doc)
      Call uiview.Print(1, 1, 1 )
      Set doc= collection.GetNextDocument(doc)
      
   Loop
   
   
End Sub

botschi

  • Gast
Ich glaube wegen
Code
call uiview.SelecteDocument(doc)
.
Versuche mal
Code
Set notesDocumentCollection = notesUIView.Documents
und dann uiview.print....

Matthias

Offline skrueger

  • Frischling
  • *
  • Beiträge: 11
-->> dann bekomme ich die Meldung "Varaint does not contain an Object " bei der Ausführung .


Sub Click(Source As Button)
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim workspace As New NotesUIWorkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim uiview As NotesUIView
   
   Set db = session.CurrentDatabase
   Set uiview = workspace.CurrentView
   Set collection = db.unProcesseddocuments
   
   Set doc= collection.GetFirstDocument
   
   
   Do Until doc Is Nothing
      
      Set notesDocumentCollection = notesUIView.Documents   
      'Call uiview.SelectDocument(doc)
      Call uiview.Print(1, 1, 1 )
      Set doc= collection.GetNextDocument(doc)
      
   Loop
   
   
End Sub

botschi

  • Gast
Aus
Code
Set notesDocumentCollection = notesUIView.Documents   
mach
Code
Set Collection = notesUIView.Documents   

Matthias

Offline ascabg

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 3.697
  • Geschlecht: Männlich
Hallo,

Sollte dies hier nicht auch funktionieren
Code
Call uiview.Print(1 , 1, 1, , 2, , False)

In Anlehnung an die Designer-Hilfe.
uiview.Print
Zitat
Prints the selected document(s) or the current view.


Andreas
« Letzte Änderung: 27.11.09 - 11:06:30 von ascabg »

Offline skrueger

  • Frischling
  • *
  • Beiträge: 11
Hi !
danke für die Rege Teilnahme. :-)
Habe den Code nochmal geändert. Aber immer noch die Fehlermeldung "Varaint does not contain an Object "
 ???



Sub Click(Source As Button)
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim workspace As New NotesUIWorkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim uiview As NotesUIView
   
   Set db = session.CurrentDatabase
   Set uiview = workspace.CurrentView
   Set collection = db.unProcesseddocuments
   Set doc= collection.GetFirstDocument
   
   Do Until doc Is Nothing
      
      Set Collection = notesUIView.Documents   
      Call uiview.Print(1, 1, 1 )
         
      Set doc= collection.GetNextDocument(doc)
      
   Loop
   
   
End Sub

Offline ascabg

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 3.697
  • Geschlecht: Männlich
Zum Einen.
Nimm die Anweisung zum Drucken mal aus der Schleife heraus.

Zum Anderen.
Wo hast Du denn den Button (ich nehme mal an es ist einer) eingebaut?
Und auch, was sagt denn der Debugger?
An welcher Stelle Deines Code kommt es zu dem besagten Fehler?


Andreas

botschi

  • Gast
Die Collection wird leer sein...

Matthias

Offline skrueger

  • Frischling
  • *
  • Beiträge: 11
Es ist eine aktion in einer ansicht.
Ich bin nicht sehr fit mit script :-) deshalb meine vielen fragen.


Offline Hatschi

  • Junior Mitglied
  • **
  • Beiträge: 96
Hallo,

warum wird in der Schleife die Collection neu gefüllt? Damit überscheibst du dir doch die vorher übernommenen unprocessedDocuments.

Kommentiere die Zeile in der Schleife
Set Collection = notesUIView.Documents   
einmal aus.

Auch mich würde interessieren an welcher Stelle die Fehlermeldung kommt. Wieviele Dokument zeigt der Debugger in der Collection an, wenn er in die Schleife kommt?

Bernd




Offline Klafu

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.944
  • Geschlecht: Männlich
  • Remember the Cookies!
Hier mal ein Beispielcode wie er hier im Forum zu finden ist:
vielleicht vergleichst mal die Kernfunktionen mit deinem Code

Hier druckt er über einen PDF Drucker

Code
Sub Initialize
' -------------------------------------------------------------------
' --- Deklarationen / Settings
' -------------------------------------------------------------------
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc, docPG As NotesDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim dc As NotesDocumentCollection
Set dc = db.UnprocessedDocuments
ok = Messagebox("Wollen Sie die " & dc.Count & " ausgewählten Dokumente mit dem PDFCreator konvertieren?", 4+32, "PDFCreator | Konverter")
If ok = 7 Then Exit Sub
' -------------------------------------------------------------------
' --- Globale Konfiguration einlesen
' -------------------------------------------------------------------
Set docPG = db.GetProfileDocument("($Config)")
cfg_pcspfad = docPG.cfg_PCSPfad(0)
If Right(cfg_pcspfad, 1) <> "\" Then cfg_pcspfad = cfg_pcspfad & "\"
cfg_pcsfile = docPG.cfg_PCSFile(0)
cfg_pcsattfile = docPG.cfg_PCSAttFile(0)
cfg_pcsformat = Lcase(docPG.cfg_PCSFormat(0))
cfg_pcsfile = cfg_pcsfile & "." & cfg_pcsformat
' PDFCreator "simuliert" Verwendung des PDF Servers (Felder setzen)
cfg_pcs_epdfsim = docPG.cfg_PCS_ePDFSim(0)
If cfg_pcs_epdfsim <> "" Then
cfg_resultcodegw = docPG.ResultCodeGW(0)
If cfg_resultcodegw = "" Then cfg_resultcodegw = "131"
cfg_pcsfile = docPG.cfg_ePDF_OutputFileName(0)
End If
fpath = cfg_pcspfad
ffile = cfg_pcsfile
' -------------------------------------------------------------------
' init PDFCreator
Set oPDFC  = CreateObject("PDFCreator.clsPDFCreator")
oPDFC.cStart("/NoProcessingAtStartup")
oPDFC.cOption("UseAutosave") = 1
oPDFC.cOption("UseAutosaveDirectory") = 1
oPDFC.cOption("AutosaveFormat") = 0    ' 0=PDF, 1=PNG, 2=JPG, 3=BMP, 4=PCX, 5=TIFF, 6=PS, 7= EPS, 8=ASCII
DefaultPrinter = oPDFC.cDefaultprinter
oPDFC.cDefaultprinter = "PDFCreator"
oPDFC.cClearCache
oPDFC.cOption("AutosaveDirectory") = fpath
oPDFC.cOption("AutosaveFilename") = ffile
Set doc = dc.GetFirstDocument
unid = doc.UniversalID
c = 0
Do Until doc Is Nothing
c = c + 1
oPDFC.cPrinterStop = True
' document was already converted
If doc.ePDF_flg(0) > "" Then
Print "Document was alreday converted!"
Goto weiter
End If
' print NotesDocument at first ...
i = 1
Set uidoc = ws.EditDocument (False, doc)
Call uidoc.Print(1)
Call uidoc.Close(True) ' If True, the document is immediately closed. If False, closing the document may be delayed
Set rtitem = doc.GetFirstItem( "Body" )
If Not doc.HasEmbedded Then
Goto no_object
End If
If Not rtitem Is Nothing And rtitem.Type = RICHTEXT Then
Forall o In rtitem.EmbeddedObjects
i = i + 1
Print fpath & o.Name
Call o.ExtractFile( fpath & o.Name )
' check if attachment is printable
isPrintable = oPDFC.cIsPrintable(fpath & o.Name)
If isPrintable = False Then
Print "Converting: " & unid & " " & o.Name &  " An error is occured: File is not printable! ", 0+16, ""
Goto weiter ' Weiter mit nächstem Dokument
End If
' and now print all attachments
Print "Printing -> " & fpath & o.Name
oPDFC.cPrintfile(fpath & o.Name)
End Forall
End If
no_object:
' count print jobs in queue
Do Until oPDFC.cCountOfPrintjobs = i
Doevents
Loop
' combine all print jobs to one document
oPDFC.cCombineAll
oPDFC.cPrinterStop = False
' let PDFCreator print all jobs from queue
Do Until oPDFC.cCountOfPrintjobs = 0
Doevents
Loop
' release
Sleep(.1)
oPDFC.cDefaultprinter = DefaultPrinter
oPDFC.cClearcache
Sleep(.1)
' attach created PDF file
If cfg_pcsattfile <> "" Or cfg_pcs_epdfsim <> "" Then
Set rtitem = doc.GetFirstItem("Body")
If rtitem Is Nothing Then
Set rtitem = doc.CreateRichTextItem( "Body" )
End If
Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", fpath & ffile )
If cfg_pcs_epdfsim <> "" Then
doc.ePDF_flg = Date$ & " " & Time$ & " PDFCreator"
doc.ResultCodeGW = cfg_resultcodegw
End If
Call doc.Save( True, True )
End If
Print "Converting document " & c & " / " & dc.Count
weiter:
Sleep(1)
Set doc = dc.GetNextDocument(doc)
Loop
Set oPDFC = Nothing
Print dc.Count & " Dokumente verarbeitet."
Dim uiview As NotesUIView
Set uiview = ws.CurrentView
Call uiview.DeselectAll
Exit Sub
error_handle:
' Handle your own error handle ... ;-p
End Sub

Chris
„Der einzige Mensch, der sich vernünftig benimmt, ist mein Schneider. Er nimmt jedesmal neu Maß, wenn er mich trifft, während alle anderen immer die alten Maßstäbe anlegen in der Meinung, sie paßten auch heute noch...“

Offline dirk_2909

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.173
  • Geschlecht: Männlich
  • Expand your Notes Client with ECM functionality..
    • d.velop
In der Zeile

Code
Set Collection = notesUIView.Documents   

verwendest Du das Object/Variable notesUIView. Das hast Du aber nirgendwo deklariert bzw. initialisiert ;-)
Du verwendest aber sonst die Variable "uiview". Diese soltest Du entsprechend verwenden:


Code
Set collection = uiview.Documents
   
Dirk

[IBM CLP R5]
[IBM CAD 6/6.5]
[IBM CAD 7]
[IBM CAD 8]


"Nein!! … Es genügt nicht Mails in einen anderen Ordner oder Datenbank zu verschieben, um sie zu archivieren!"

   
Disclaimer:
Ich Antworte nach besten Wissen und Gewissen. Sollte sich jemand durch meine Antwort persönlich angegriffen fühlen, ist dies nicht meine Absicht!
Ich bin auch nur ein Mensch, der Fehler machen kann. ....

Offline skrueger

  • Frischling
  • *
  • Beiträge: 11
vielen Dank für die grosse Anteilnahme  :)
Da ich etwas unter Zeitdruck war und mein Script-KnowHow noch nicht so gut ist, hab ich es über Formel-Sprache gelöst.
@Command( [FilePrint] ; ""; "1";" 1";"" ; "" ;"" ; "pagebreak"; "resetpages"; ""; "").
Versuche Eure Vorschläge aber nochmal aus, damit ich im Script-Bereich mal fitter werde.
Nochmals vielen Dank.

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz