Allow user to attach file

I had received help in creating the agent below to load pdf files from a specific location. The question now is can I put this code into a button that allows a user to pull a specific document from the file. Can I get them a messagebox asking for the budget number or something to identify the file?

'Attach PDFs (ALL) and load into view

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Dim pathName As String, fileName As String

Dim filesToGet As String, filePathName As String



pathName$ = "S:\IS\Report_Export_Test\Endow_to_lotus\Final\FinishedFinancial06\"

filesToGet$ = pathName$ + "*.pdf"

fileName$ = Dir$(filesToGet$, 0 )



Set db = session.CurrentDatabase



Do While fileName$ <> "" 

	Set doc = New NotesDocument( db )

	Set rtitem = New NotesRichTextItem( doc, "pdf" ) 'in quotes = attachment field name

	filePathName$ = pathName$ + fileName$

	Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", filePathName$) 

	doc.Form = "donorpdf2006"

	doc.fy = 2006

	doc.fullbudget = fileName$

	Call doc.Save( True, True )

	fileName$ = Dir$( )

Loop

End Sub

Subject: Allow user to attach file

take a look at the picklist method - substitute the “FileName$” for the return value from the picklist

Example Picklist Method

Creates a string array from a list selected by the user.

The first form of the method displays the Names, Rooms or Resources dialog box for a Domino Directory.

The second form allows you to customize a list of documents from any database.

Note This method is new with Release 5.

Defined in

NotesUIWorkspace

Syntax

stringArray = notesUIWorkspace.PickListStrings( type% [, multipleSelection ] )

stringArray = notesUIWorkspace.PickListStrings( type% [, multipleSelection ], server$, databaseFileName$, viewName$, title$, prompt$, column% [, categoryname$ ] )

Parameters

type%

Integer. The type of view that you specify. The legal values for this parameter are as follows:

PICKLIST_NAMES (0) Displays the names dialog box. Can only be used in the first form of the method.

PICKLIST_ROOMS (1) Displays the rooms dialog box. Can only be used in the first form of the method.

PICKLIST_RESOURCES (2) Displays the resources dialog box. Can only be used in the first form of the method.

PICKLIST_CUSTOM (3) Displays the dialog box for the view that you specify. Can only be used in the second form of the method.

multipleSelection

Boolean. Optional. Specify True if you want to select multiple documents. Defaults to False.

server$

String. Name of the server where the database resides.

databaseFileName$

String. The filename of the database that contains the view.

viewName$

String. Name of the view that you want displayed in the dialog box.

title$

String. Title for the dialog box.

prompt$

String. The prompt that you want to appear inside the dialog box.

column%

Integer. The column value that you want returned.

categoryname$

String. Optional. Displays the specified category in the view. The view should be categorized in order to use this parameter.

Return value

This method returns a variant containing a string array if you click OK, or it returns EMPTY if you click Cancel.

Language cross-reference

@PickList function in formula language

Example

See Also

PickListCollection method

Glossary Feedback on Help or Product Usability?

Subject: Allow user to attach file

It would a little precarious to prompt them for the filename, because they would have to type it in EXACTLY in order for it to be found. It would be better to give them a list of files in a directory so they can just choose the file they want.

Copy this code into a button and then use the While loop to construct an array of filenames in the directory. Use uiws.prompt(prompt_okcancellist…) to prompt for their choice and then use their selection to get the right file and attach it.

hth

Subject: RE: Allow user to attach file

Where would I put the while loop? I am just now getting back to this project . . . sorry for the delay.

Thank you.