Tip

Printing All Attachments From A Document

This LotusScript provide you the ability to print all attachments from a
document (or a list of documents). This is only usable for WIN32.
There is noot the ability to print crypt message of document. Improuvements
will be appreciate.
A special thank to Sylvain Coste and Loic Fabro for theiir great help.
THE SCRIPT FOR LAUNCH PRINT PROCESS
@Command( [FilePrint] ; "" ; ""; ""; ""; ""; ""; "";
"";"";"");@Command([ToolsRunMacro];"(ImprPiecesJointes)")

(Declarations)
As StringDim ret As IntegerDim NewDoc As NotesDocumentDim Noms As
VariantDeclare 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
LongSub Initialize
Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument Dim Session As New NotesSession
Dim db As NotesDatabase
Set db = Session.CurrentDatabase Dim doc As NotesDocument
Set doc = session.DocumentContext Dim LogFileNumber As Integer Dim
LogFileName As String
Dim hwnd As Long 'the windows handle don't need to initalize
Dim lpOperation As String
Dim lpFile As String
Dim lpParameters As String
Dim lpDirectory As String
Dim nShowCmd As Long
Dim Hwin32 As Long 'the windows target handle dont need to initalize
Dim Ret As Integer
Randomize
TmpRep= RendTmpRepertoire
If TmpRep = "" Then Msgbox "Error tmp no found" , 16 , "Directory
error"
Exit Sub
End If
Ret = ModeleDetachePourVueUI( db ) If Ret = False Then
Msgbox "Detach error"
Exit Sub
End If
Dim j As Integer ' open report file
LogFileNumber = Freefile() LogFileName = "prn_rep.txt"
Open TmpRep & "\" & LogFileName For Output As LogFileNumber
Print #LogFileNumber, "Doc Proccess :" Print #LogFileNumber, " "
If Not Isempty(Noms) Then For j = 0 To Ubound(Noms) lpFile
= Noms(j) 'Describe the file name lpDirectory = TmpRep 'Describe
file location
nShowCmd =0 'Show the open file lpOperation = "Print" 'if
you want to open the file change to "Open" ' and finally execute
the action on the file
Hwin32 = ShellExecute(hwnd, lpOperation, lpFile, "", lpDirectory, nShowCmd)

Next
Close
LogFileNumberHwin32 = ShellExecute(hwnd, lpOperation, LogFileName, "",
lpDirectory, nShowCmd)End IfEnd SubFunction RendTmpRepertoireOn Error Goto
err_env RendTmpRepertoire= Environ("TEMP")Exit Functionerr_env:
Msgbox "TEMP doen't exist."
RendTmpRepertoire = ""
Exit Function
End Function
Function ModeleDetachePourVueUI (db As NotesDatabase) As Integer
ModeleDetachePourVueUI = True Dim workspace As New NotesUIWorkspace Dim
view As NotesView
Dim doc As NotesDocument
Dim embobj As NotesDocument
Dim collection As NotesDocumentCollection
Dim rtitem As Variant
Dim NomsDocCourant As Variant Dim NbNoms As Integer
Set collection = db.UnprocessedDocuments
For jj = 1 To collection.Count Set doc = collection.GetNthDocument( jj
)
If doc Is Nothing Then
ModeleDetachePourVueUI = True
Exit Function
End If

Const Const Noms "@AttachmentNames" NomsDocCourant =
Evaluate(ConstNoms ,doc)
NbNoms = Ubound(NomsDocCourant) If Trim( NomsDocCourant(0)) <> ""
Then
For i = 0 To NbNoms
Set rtitem = doc.GetAttachment( NomsDocCourant(i) )
If rtitem.Type = EMBED_ATTACHMENT Then Print "File detach
"+NomsDocCourant(i) Print tmprep & "\" & NomsDocCourant(i)

NouveauNomFichier = Trim(Left$(NomsDocCourant(i), 4))
If Instr(NouveauNomFichier, ".") > 0 Then NouveauNomFichier =
Trim(Left(NouveauNomFichier, Instr(NouveauNomFichier, ".") - 1))
End If
Aleatoire = Trim(Str( Round(Rnd() * 10000,0)))
NouveauNomFichier = NouveauNomFichier & Aleatoire
ExtensionFichier = Trim(NomsDocCourant(i))
While (Instr(ExtensionFichier, ".") > 0)
ExtensionFichier = Trim(Right$(ExtensionFichier, Len(ExtensionFichier) -
Instr(ExtensionFichier, ".")))
Wend
If Len(ExtensionFichier) > 3 Then
ExtensionFichier = Left$(Extensi

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.