Script To Print Automatically All The .Xls Or .Doc Or .Ppt Attachments In Documents

This script will print all the .xls or .doc or .ppt attachments in selected
documents in a view. This is very useful in maildatabases. user doesn't need to
launch each attachment in each document. I am not very good at OLE. but while
helping a friend I came up with this script. If it needs any modification or
if any one have any better method please modify the script and post in this
forum.

Thanks.
Surendra Kumar Talluri
Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim dc As notesdocumentcollection
Dim rtitem As notesrichtextitem
Dim loopindex As Long
Dim poc As Integer
Dim resul As String
Dim xlapp As Variant
Set db = session.currentdatabase
Set dc = db.Unprocesseddocuments
For loopindex = 1 To dc.count
Set doc = dc.getnthdocument(loopindex)
If (doc.hasitem("$File")) Then
Set rtitem = doc.getfirstitem("Body")
Forall eo In rtitem.embeddedobjects
If (eo.Type= EMBED_ATTACHMENT) Then
fname = "C:\TEMP\" & eo.Source
poc = Instr(1, fname, ".")
resul = Mid$(fname, poc, 4)

If Lcase$(resul) = ".xls" Then
Call eo.extractfile(fname)
Set xlapp = createobject("Excel.application")
xlapp.visible = True
xlapp.workbooks.open (fname)
Print("Printing Attachment : "&eo.Source)
Call xlapp.Activesheet.printout
' the follwing loop is to avoid any warning
message the 'application prompts some times like
" the current document is 'still in the
process of printing. do you want to continue printing
or 'cancel"
For i =1 To 100000
Next
Call xlapp.workbooks.close
Call xlapp.quit
End If
If Lcase$(resul) = ".doc" Then
Call eo.extractfile(fname)
Set xlapp = createobject("Word.application")
xlapp.visible = True
xlapp.documents.open(fname)
Print("Printing Attachment : "&eo.Source)
xlapp.PrintOut(FileName=fname)
For i =1 To 100000
Next
xlapp.Quit savechanges=False
End If
If Lcase$(resul) = ".ppt" Then
Call eo.extractfile(fname)
Set xlapp = createobject("PowerPoint.application")
xlapp.visible = True
xlapp.presentations.open(fname)
Print("Printing Attachment : "&eo.Source)
xlapp.ActivePresentation.PrintOut
For i =1 To 100000
Next
xlapp.activepresentation.close
xlapp.Quit
End If
End If
End Forall
Print(" ")
End If
Next
End Sub
This was first published in November 2000

Dig deeper on Domino Resources

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close