Subject: replacing pics - solution
Assuming your images are stored as file attachments within the employee documents and not embedded as a graphic you can place the following script in the PostRecalc event of your form to accomplish what you need.
Dim s As New NotesSession
Dim db As NotesDatabase
Dim images As NotesView
Dim image As NotesDocument
Dim rtField As Variant
Dim exportFile As String
Set db = s.Currentdatabase
Set images = db.GetView("ImageLkup")
'Get the image document for the selected employee in the drop down list
Set image = images.GetDocumentByKey( Source.document.EmployeeName(0), True )
If Not( image Is Nothing ) Then
Set rtField = image.GetFirstItem("Image")
If rtField.Type = RICHTEXT Then
Forall o In rtField.EmbeddedObjects
exportFile = "c:\temp\" & o.Source
Call o.ExtractFile( exportFile )
Exit Forall
End Forall
End If
'******************************************
'Clear out the current contents of the rich text field that will contain the image
Call Source.FieldSetText("EmployeeImage", "T") 'Store something in the rich text field so that we have something to select and then clear. Needed in case the RT field is initially empty
Call Source.GotoField("EmployeeImage")
Call Source.SelectAll
Call Source.Clear
'********************************************
'Import the selected employee’s image
Call Source.Import( "GIF Image", exportFile )
Kill exportFile
Else
Call Source.FieldSetText(“EmployeeImage”,“Image not found.”)
End If
Your dialog list field must be set to refresh on keyword change. You must have a c:\temp directory defined or the extract will fail. You will have to check the type of file that is being exported to determine the appropriate import filter for the Import method of the NotesUIDocument (for example JPEG Image for .jpg GIF Image for .gif, etc.).
I’ve tested this and this works just fine.
Give it a shot and let me know if you have any questions.