Manage Learn to apply best practices and optimize your operations.

File Open/Attach Via Dialog For R4.X

A few weeks ago, I was trying to help another developer who was still using
R4.6. He needed a routine to display a File-Open dialogbox, select a file and
attach it to the open document. We were able to get most of the way using
@Prompt([LOCALBROWSE]) which is undocumented in R4.6, but still works. However,
it always started in the NOTES\DATA directory, and there wasn't any way to pass
it a different initial directory to display.

The following accomplishes that function and more... The wName string variable
passes the initial directory into the function and holds the selected filename
after the user clicks OK.

The wTypeList string passes file-type filters into the function that the user
can select from a drop-down list. You can have multiple filters, separated by a
vertical bar, but each filter must have two elements, also separated by a
vertical bar (1) the label to be displayed in the drop-down list and (2) the
file-system filter (i.e. *.doc for MSWord documents) that determines which
files display when that filter is selected. The first filter-pair in wTypeList
is the default.

This script is suitable for an action button or hotspot on a form, however, the
attachment will not show up on the document until after it has been saved and
closed.
' Paste the following line in the [Declarations] section of the Action

Declare Function NEMGetFile Lib "nnotesws" ( wHandle As Integer, Byval wName As
String, Byval wFilter As String, Byval wTitle As String ) As Integer


Sub Click(Source As Button)

'Declare variables...
Dim ws As New NotesUIWorkspace
Dim ui As NotesUIDocument
Dim doc As NotesDocument
Dim rt As NotesRichTextItem
Dim wHandle As Integer
Dim wName As String*256
Dim wTypeList As String
Dim wDlgLabel As String
Dim wReturnedFile As String

' Assign parameter values
Set ui = ws.CurrentDocument
Set doc = ui.Document
If doc.HasItem("Attachments") Then
Set rt = doc.GetFirstItem("Attachments")
Else
Set rt = New NotesRichTextItem(doc, "Attachments")
End If
wHandle = 0
wName = "C:\"
wTypeList = "All files|*.*|Text files|*.txt"
wDlgLabel = "Attach File"

If NEMGetFile( wHandle, wName, wTypeList, wDlgLabel) <> 0 Then ' Returns 0
if user hits CANCEL
wReturnedFile = wName
Call rt.EmbedObject(EMBED_ATTACHMENT, "", wReturnedFile)
End If
End Sub

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

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 ...

SearchDataCenter

SearchContentManagement

Close