358 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Jobs | Twitter | Bookmarks | Pods | Forum | Blogs | Search | myPL | About 
 
Latest 7 Posts
False Positives on Planet Lotus
Fri, Sep 25th 2009 31
Validating URL and Email Addresses with regexp in Lotus Notes
Thu, Sep 17th 2009 95
can’t use @ThisName in Hide-When formulas, LOTUS NOTES meta coding FAIL
Fri, Sep 11th 2009 52
Expanding Group Names for Lotus Domino using LotusScript
Tue, Sep 8th 2009 198
SNTT: a pseudo Computed for Display Rich Text Field in the Lotus Notes Client
Thu, Sep 3rd 2009 75
Sacha Chua shares her Lotus Notes mail merge from a Microsoft Excel spreadsheet
Thu, Aug 27th 2009 64
SNTT : using LotusScript to launch file attachements (EmbeddedObjects) in Lotus Notes
Wed, Aug 26th 2009 194
Top 10
Expanding Group Names for Lotus Domino using LotusScript
Tue, Sep 8th 2009 198
SNTT : using LotusScript to launch file attachements (EmbeddedObjects) in Lotus Notes
Wed, Aug 26th 2009 194
Stopping Copy and Paste, in Lotus Notes, selectivity in Views
Thu, Jul 30th 2009 107
SNTT : Validating a Notes Client Rich text field
Thu, May 7th 2009 99
Validating URL and Email Addresses with regexp in Lotus Notes
Thu, Sep 17th 2009 95
SnTT: Notes Document Structured Text Export for Multilingual (UTF-8)
Thu, Nov 15th 2007 93
SNTT: a pseudo Computed for Display Rich Text Field in the Lotus Notes Client
Thu, Sep 3rd 2009 75
Sacha Chua shares her Lotus Notes mail merge from a Microsoft Excel spreadsheet
Thu, Aug 27th 2009 64
can’t use @ThisName in Hide-When formulas, LOTUS NOTES meta coding FAIL
Fri, Sep 11th 2009 52
Weird Wonderful Web Links for January 21st
Mon, Jan 21st 2008 32


SNTT : using LotusScript to launch file attachements (EmbeddedObjects) in Lotus Notes
Ian    

I wanted to launch a excel (xls) file which was stored in a Profile document, from a Notes Client (tested in r8.5 but I see no reason this will not work in versions going back to r5)

(Making it available to all users of a certain type of document with making hundreds of replicate copies, and all a central db administrator user able to roll out a new file with out changing those other documents)

It is not very obvious how to do this, hence this posting

My first Draft was this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Dim  workspace As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim Pdoc As NotesDocument
    Dim attachments As Variant
    Dim attachment As NotesEmbeddedObject  

    Set db = session.CurrentDatabase
    Set Pdoc = db.GetProfileDocument("ApplicationProfileDocument" ) ' get the profile document

    attachments = Evaluate("@AttachmentNames", Pdoc)
    Set attachment = Pdoc.GetAttachment(attachments(0)) 'use a evalutate to get the first "(0)" file attachment
   
    Call attachment.ExtractFile("c:" & attachment.Name)     ' write it out to the hard drive
    Set e = CreateObject("Excel.Application")                       ' open excel
    Set eWB = e.Workbooks.Open("c:" & attachment.Name)  ' open the file in excel
    eWB.Visible = True                                     'make the opened excel file visible

There was a problem the that code in that I could be sure that there weren’t other file attachments and the first one was going to be the one I wanted.

I’ve tried to correct that problem here :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Dim  workspace As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim Pdoc As NotesDocument
    Set db = session.CurrentDatabase
    Set Pdoc = db.GetProfileDocument("ApplicationProfileDocument" )
       
    Set rtitem = Pdoc.GetFirstItem( "RichTextFilewithFileAttacment" ) 'get the field I know the file is in.
    If ( rtitem.Type = RICHTEXT ) Then
        Forall o In rtitem.EmbeddedObjects
            If ( o.Type = EMBED_ATTACHMENT )  Then
                Call o.ExtractFile ("c:" & o.Name)      ' write it out to the c: hard drive    
                Set e = CreateObject("Excel.Application")  ' open  excel
                Set oWB = e.Workbooks.Open("c:" & o.Name)   ' open the file in excel
                oWB.Visible = True            'make the opened excel file visible
            End If
        End Forall     
    End If

This will actually launch all the files that are attached in the rich text (or rich text light) field, which I could limit by doing some validation work on the Profile form to ensure only 1 file is attached.

2 (possibly) big assumptions :

  1. This is a windows machine with a c: drive and enough free space. this is testable but I’m too lazy/busy/silly (please only pick one).
  2. The file to be launched is an Excel. This could be allow for be testing the file name extension and doing the appropriate thing. (and that assumes the MS Excel is the application for that file extension and the Open Office, or something similar).

update: Collin and Sean both make go points and reminded me of another thing : Execution Control List’s (ECL) which control access on the Notes Client. You may need to get the notes database signed with a ID that has right to write to the file system in your organization, or your end users will be prompted with a “Execution Security Alert” with will ask them to either stop the action, execute once or trust the id used.

Post from: False Positives

SNTT : using LotusScript to launch file attachements (EmbeddedObjects) in Lotus Notes



---------------------
http://www.falsepositives.com/index.php/2009/08/26/sntt-using-lotusscript-to-launch-file-attachements-embeddedobjects-in-lotus-notes/
Aug 26, 2009
202 hits



Recent Blog Posts
31


False Positives on Planet Lotus
Fri, Sep 25th 2009 9:56a   Ian Irving
[read] Keywords: domino lotus notes sntt community firefox google php planet lotus planetlotus planetlotus.org
95


Validating URL and Email Addresses with regexp in Lotus Notes
Thu, Sep 17th 2009 9:57a   Ian Irving
[read] Keywords: lotus lotusscript notes sntt email php
52


1
can’t use @ThisName in Hide-When formulas, LOTUS NOTES meta coding FAIL
Fri, Sep 11th 2009 12:31p   Ian Irving
[read] Keywords: dblookup document formula formula language lotus notes sntt idea jam ideajam ideajam.net php properties
198


Expanding Group Names for Lotus Domino using LotusScript
Tue, Sep 8th 2009 10:09a   Ian Irving
[read] Keywords: acl document domino lotus lotusscript notes notes client rich text rich-text sntt php server
75


SNTT: a pseudo Computed for Display Rich Text Field in the Lotus Notes Client
Thu, Sep 3rd 2009 4:16p   Ian Irving
[read] Keywords: document formula lotus lotusscript notes notes client rich text rich-text sntt idea jam ideajam ideajam.net php profile workspace
64


Sacha Chua shares her Lotus Notes mail merge from a Microsoft Excel spreadsheet
Thu, Aug 27th 2009 9:40a   Ian Irving
[read] Keywords: document domino lotus notes sntt microsoft php




195


SNTT : using LotusScript to launch file attachements (EmbeddedObjects) in Lotus Notes
Wed, Aug 26th 2009 10:13p   Ian Irving
[read] Keywords: admin document domino ibm lotus lotusscript notes notes client R5 R8 rich text richtext rich-text sntt application database office php profile security workspace
20


SNTT : Don’t hard code your Selectedable Years in a Lotus Notes dialog box.
Thu, Aug 13th 2009 3:39p   Ian Irving
[read] Keywords: acl dblookup lotus lotusscript notes sntt php
16


SNTT adding http onto URL strings in Lotus Notes
Thu, Aug 13th 2009 6:20a   Ian Irving
[read] Keywords: document formula formula language lotus lotusscript notes sntt java php
107


Stopping Copy and Paste, in Lotus Notes, selectivity in Views
Thu, Jul 30th 2009 1:41a   Ian Irving
[read] Keywords: acl agent document formula formula language lotus lotusscript notes notes client sntt database php




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - FAQ - Mobile Edition