Lotus Notes 8.5 print attachments

15 pts.
Tags:
Lotus Notes
Lotus Notes 8.5.1
Lotus Notes attachments
Lotus Notes printing
Windows XP SP3
How can i print attachments without opening attachment in Lotus Notes 8.5.05 ver

Software/Hardware used:
windows xp sp3 with Lotus Notes 8.5.5 version

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hello, you could create a button in the form which will call an agent :
@Command( [ToolsRunMacro] ;  “(PrintPJ)” )

Then you create the agent (in LotusScript) named “(PrintPJ)”
This is the code for this agent

Option Public
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (Byval hwnd As Long, Byval lpOperation As String, Byval lpFile As String, Byval lpParameters As String, Byval lpDirectory As String, Byval nShowCmd As Long) As Long

Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&

' ***App Window Constants***
Const WIN_NORMAL = 1 	'Open Normal
Const WIN_MAX = 3 			'Open Maximized
Const WIN_MIN = 2 			'Open Minimized



Sub Initialize
	
	' ============================================================================================================
	' ======  Cette fonction permet d'imprimer les fichiers ou pieces jointes du document ouvert en : 
	' ====== 1) Recherchant tous les champs de type TextRiche
	' ====== 2) Recherchant dans chacun des champs RT trouvés tous les fichiers qui y sont contenus
	' ====== 4) Impression par le logiciel qui les a créé (si installé sur le poste !) via les API WINDOWS
	' =============================================================================================================
	
	' Declaration des objets 
	Dim session As New NotesSession
	Dim ws As New NotesUIWorkSpace	
	
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim uiview As notesuiview
	Dim collec As NotesDocumentCollection
	Dim doc As NotesDocument
	Dim uidoc As NotesUIDocument
	Dim rtItem As NotesRichTextItem 
	Dim object As NotesEmbeddedObject 
	
	' Déclarations des variables
	Dim tabTemp As Variant, tabEmbed As Variant, tabFichier() As Variant, tabChamp() As Variant
	Dim  nChamp As Integer, nPj As Integer, nChoix As Integer
	
	Set uidoc = ws.CurrentDocument
	If uidoc Is Nothing Then
		
		' On est peut etre dans une vue  ou un dossier ....
		Set uiview = ws.CurrentView
		Set collec = UIView.Documents
		If collec.count > 0 Then
			
			Set doc = collec.GetFirstDocument
			Do While Not doc Is Nothing	
				Call PrintPJ( ws, doc )
				Set doc = collec.GetNextDocument( doc ) 
			Loop
			
		Else 
			Exit Sub
		End If
		
	Else
		
		Set doc = uidoc.document
		Call PrintPJ( ws, doc ) 
		
	End If
	
	
	
End Sub
Function PrintPJ( wsRecu As NotesUIWorkSpace, docRecu As NotesDocument ) 
	
	
	Dim sChemin As String,  sFichier As String
	Dim lpOperation As String, lpParameters As String
	Dim nShowCmd As Long, Hwin32 As Long, hwnd As Long
	
	nShowCmd =  WIN_MIN
	lpOperation = "Print"  
	' lpOperation = "Open"   			'If you want get a printed copy of Filename,change this for "Print"	
	
	' Recuperation (variable d'environnement systeme) du path pour repertoire temporaire
	sChemin = Environ("Temp")
	If sChemin <> "" Then
		sChemin = sChemin + "\"
	Else
		sChemin = "C:\"
	End If
	
	' On recherche tous les champs de type TexteRich  du document
	nChamp = 0
	Forall item In docRecu.Items
		If item.Type = RICHTEXT Then
			Redim Preserve tabChamp( nChamp ) 
			tabChamp( nChamp ) = item.Name
			nChamp = nChamp + 1
		End If			
	End Forall 
	
	' Est ce qu'il y en a ?
	If  Isempty( tabChamp ) Then 
		Print "Ce document ne contient aucune pièce jointe !"
		Exit Function 
	End If	
	
	Print "Patience ... Préparation en cours"		
	nPj = 0
	
	' On cherche les pieces jointes dans chaque champ de type Text Riche
	For nChamp = 0 To Ubound( tabChamp ) 
		Set rtitem = docRecu.GetFirstItem( tabChamp( nChamp )  )
		If Not rtitem Is Nothing Then	
			tabEmbed = rtitem.EmbeddedObjects 	
			If Not Isempty(tabEmbed) Then				
				' On parcours toutes les pieces jointes pour recuperer les noms des ficheirs
				Forall embobj In rtitem.EmbeddedObjects
					If embobj.Type = EMBED_ATTACHMENT Then
						sFichier = embobj.Name
						Set Object = docRecu.GetAttachment( sFichier)
						Call Object.ExtractFile( sChemin + sFichier )
						Print "Patience ... Impression de " + sFichier + " en cours"
						Hwin32 = ShellExecute( hwnd , lpOperation , sFichier , "" , sChemin , nShowCmd)
						
						If Hwin32 > ERROR_SUCCESS Then
							sMsg = "Impression de "  + sFichier + " lançé"
						Else
							Select Case Hwin32
							Case ERROR_NO_ASSOC:
								sMsg = "ERREUR : L'extension du fichier "+ sFichier + " est inconnue du système ! "
							Case ERROR_OUT_OF_MEM:
								smsg = "ERREUR : Pas assez de mémoire pour terminer l'opération !"
							Case ERROR_FILE_NOT_FOUND:
								sMsg = "ERREUR : Fichier " + sFichier + " inexistant !"
							Case ERROR_PATH_NOT_FOUND:
								sMsg = "ERREUR : Chemin " + sChemin + " inexistant !"
							Case ERROR_BAD_FORMAT:
								sMsg  = "ERREUR : Mauvais format de fichier !"
							Case Else:
							End Select
						End If
						Print sMsg
					End If			
				End Forall	
			End If	
		End If	
	Next nChamp 
	
	' Temporisation pour permettre au dernier document d'être imprimé AVANT sa suppression
	Sleep( 10 )
	
	' On supprime les fichiers que l'on avait détaché avant...
	For nChamp = 0 To Ubound( tabChamp ) 
		Set rtitem = docRecu.GetFirstItem( tabChamp( nChamp )  )
		If Not rtitem Is Nothing Then	
			tabEmbed = rtitem.EmbeddedObjects 	
			If Not Isempty(tabEmbed) Then				
				' On parcours toutes les pieces jointes pour recuperer les noms des ficheirs
				Forall embobj In rtitem.EmbeddedObjects
					If embobj.Type = EMBED_ATTACHMENT Then
						sFichier = sChemin + embobj.Name
						Kill sFichier
					End If			
				End Forall	
			End If	
		End If	
	Next nChamp 
	
	Print "Impression des pieces jointes terminée !"		
	
End Function

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BruceWayne
    Of course you will have to have the good sofwares installed on the PC, like MS Word to print a .DOC or .DOCX files for example
    4,465 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following