ahhh !!! je crois que je vais devenir fou !!!!
Il y a quelque chose qui m'échappe vraiment là
pour qu'il n'y ai pas d'ambiguité, je vais mettre tout le code (qui ressemble beaucoup au code d'origine qui est en ce début de post) que j'ai mis dans un bouton de formulaire :
- Code : Tout sélectionner
Sub Click(Source As Button)
On Error Goto ErrorHandler
Dim sDefaultPrinter As String, spdfname As String
Dim ws As New notesuiworkspace()
Dim vrPDFCreator As Variant, PrtNamesColl As Variant
Dim doc As notesdocument
Dim cStartedFlag As Boolean, PrinterReset As Boolean
Dim UIDocToPrint As NotesUIDocument, uidoc As NotesUIDocument
Dim PDFCreatorOptions As Variant ' PDFCreator options to restore.
Set uidoc = ws.currentdocument
Set doc = uidoc.Document
uidoc.EditMode=False
REM Récupère l'imprimante par défaut
sDefaultPrinter = PrinterDefautGet()
REM Objet qui gère l'impression
Set vrPDFCreator = CreateObject("PDFCreator.clsPDFCreator")
Set PrtNamesColl = vrPDFCreator.cGetPDFCreatorPrinters()
If vrPDFCreator.cProgramIsRunning Then
cStartedFlag = True
Else
cStartedFlag = vrPDFCreator.cStart( , True)
End If
If cStartedFlag = False Then
Msgbox("CreatePDF - PDFCreator failed to start or not installed. Process halted.")
Goto skip
End If
' Grab the current options for restoration later.
Set PDFCreatorOptions = vrPDFCreator.cOptions
With vrPDFCreator
REM Passe L'imprimante PDFCreator en imprimante par défaut
.cDefaultprinter = Cstr(PrtNamesColl.Item(1))
REM Set and save the PDFCreator options.
.cClearCache
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = Environ("Temp")
.cOption("AutosaveFilename") = Cstr(doc.UniversalID())
.cOption("AutosaveFormat") = 0
.cOption("AutosaveStartStandardProgram" ) = 0
.cOption("NoConfirmMessageSwitchingDefaultprinter") = 0
End With
Call vrPDFCreator.cSaveOptions()
Set UIDocToPrint = ws.EditDocument(False, Doc, True , "" , True , True)
'Call UIDocToPrint.Print(1 , , , PrtNamesColl.Item(1))
Call UIDocToPrint.Print(1 )
Call UIDocToPrint.Close(True)
spdfname = Environ("Temp") +"\"+ Cstr(doc.UniversalID()) + ".pdf"
REM Wait for print job to complete.
Dim counter As Integer
Counter = 0
Do Until (vrPDFCreator.cCountOfPrintJobs = 0 And Dir(spdfname) <> "" ) Or Counter = 30
Yield
Sleep 1
Yield
Counter = Counter + 1
Loop
If Counter = 30 Then
Msgbox ("CreatePDF - PDF Conversion never completed. Process halted.")
Goto skip
End If
skip:
With vrPDFCreator
REM Blocage de l'imprimante
.cPrinterStop = True
REM remet l'imprimante par défaut d'origine
.cDefaultprinter = sDefaultPrinter
REM Vide le Cache de PDFCreator
.cClearCache
End With
REM Restore and save original options, then close PDFCreator only if it had been started by this sub.
Set vrPDFCreator.cOptions = PDFCreatorOptions
REM Ferme l'application PDFCreator
Call vrPDFCreator.cSaveOptions()
Call vrPDFCreator.cClose
'Call RTIForAttachment.EmbedObject (EMBED_ATTACHMENT , "" , spdfname)
'Kill spdfname
Call doc.Save(True, False)
Call uidoc.Close(True)
Call ws.EditDocument(True, doc)
Exit Sub
ErrorHandler:
If Datatype(vrPDFCreator) <> 0 Then
If Err = 4412 Then
Call UIDoc.Close( True )
Sleep 3
End If
Call vrPDFCreator.cErrorClear()
If PrinterReset And sDefaultPrinter <> Cstr( PrtNamesColl.Item(1)) Then
vrPDFCreator.cDefaultPrinter = Cstr( PrtNamesColl.Item(1))
vrPDFCreator.cDefaultPrinter = sDefaultPrinter
End If
Set vrPDFCreator.cOptions = PDFCreatorOptions
Call vrPDFCreator.cSaveOptions()
Call vrPDFCreator.cClose()
Else
Msgbox "PDFCreator pas installé. Veuillez contacter votre répondant informatique."
Exit Sub
End If
'Msgbox " -> Error " & Err & " in line " & Erl & ": " & Error$, 64, "Error"
Exit Sub
End Sub
Je ne comprends pas la logique de lotus , je m'explique, lorsque je lance ce code en débug, je vois bien dans windows en suivant la liste des imprimante que mon imprimante par défaut change pour passer sur PDFCreator (cool) mais lorsque notes imprime le document courrant, c'est mon ancienne imprimante par défaut qui imprime mon document.
J'ai même essayé de voir si l'imprimante par défaut avait bien changé en lançant une autre application windows , et PDFCreator est bien reconnu comme imprimante par défaut.
En ce qui concerne les droits, mon poste a des droits administrateur, mais au niveau de lotus, je ne sais pas.
Je suis sous lotus 6.5, est ce que ça pourrait être ça le problème ?