Hi.Our Notes database uses a form that contains a rich text field where an image file is displayed.
The images displayed by this rich text field are all stored in a particular folder on our shared hard drive.
When someone creates a new record on the database, they embed the relevant image into this rich text field using the following process:
Open the correct image in the software used to view/edit the images
Select ‘Copy’ in the software
Click in the rich text field in the Notes form (in ‘Edit’ mode)
Select ‘Paste Special’ in Notes and select the option to paste the object into the field as a link
Save the record.
This embeds the image object in the rich text field as a link, so that when the image is double-clicked in the Notes form it is automatically opened in the software that we used to view and edit the images.
My question is this: Is it possible to use code (preferably LotusScript) to get the full filepath for these embedded images in the Notes form?
I would like to be able to look at the filepaths of all the images stored in the database records, so I can check that the each image file is linked in to the correct record.
Thanks for your help.
Subject: Getting the filepath of an object embedded as a link in a rich text field
I’m including code for two actions that I’ve used on a form to both attach images and to view them. At the time they are attached, I grab the path and store it seperately.
FYI, the view code opens the image in photoshop. YOu can change this.
Hope it helps or at least points you in the right direction. Good luck.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim workflowview As NotesView
Dim workflowdocument As Notesdocument
Dim filenames
Dim askme As Integer
Dim msgTemp As String, defaultLoc As String
Set workspace = New NotesUIWorkspace
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set workflowview = db.GetView( "Workflow" )
Set workflowdoc = workflowview.GetDocumentByKey( "Workflow" )
If Not(workflowdoc Is Nothing) Then
defaultLoc = workflowdoc.InitDir(0)
Else
defaultLoc = "C:\"
End If
If uidoc.Document.PicturesFileName(0) <> "" Then
REM If the picture has been marked as an issue, then clear it by default
If uidoc.Document.PictureNotFound(0) = "Yes" Then
uidoc.Document.PictureNotFound = ""
askme = 1
msgTemp = "The pictures on this document were not all found." + Chr(10) + Chr(10) + _
"You will need to reselect them to clear up the issue."
askme = workspace.Prompt( PROMPT_OK, "Reselect Pictures", msgTemp)
Else
msgTemp = "Do you want to clear the existing picture filenames" + Chr(10) + "already on " + _
"this document and reselect new ones?" + Chr(10) + Chr(10) + "Click 'Yes' to clear them, " + _
"'No' to append to your list."
askme = workspace.Prompt( PROMPT_YESNO, "Clear of Append Filenames", msgTemp)
End If
If askme = 1 Then
uidoc.Document.PicturesFileName = ""
End If
End If
filenames = workspace.OpenFileDialog(True, "Select files to be attached", "", defaultLoc)
If Not(Isempty(filenames)) Then
Forall filename In filenames
If uidoc.Document.PicturesFileName(0) = "" Then
uidoc.Document.PicturesFileName = filename
Else
If Instr(1, uidoc.Document.PicturesFileName(0), filename, 5) = 0 Then
uidoc.Document.PicturesFileName = uidoc.Document.PicturesFileName(0) + "^" + filename
End If
End If
End Forall
Call uidoc.Refresh
End If
End Sub
Sub Click(Source As Button)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim workflowview As NotesView
Dim workflowdoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim item As NotesItem
Dim result As Integer, count As Integer
Dim response As Variant
Dim tempVal As String
Set db = session.CurrentDatabase
Set workflowview = db.GetView( "Workflow" )
Set workflowdoc = workflowview.GetFirstDocument
Set uidoc = workspace.CurrentDocument
Set item = uidoc.document.GetFirstItem( "PicturesFileName" )
count = 0
REM Determine if there are multiple pictures on this document.
Forall v In item.Values
count = count + 1
End Forall
REM If multiple pictures exist on this document, prompt user to choose which one to open.
If count > 1 Then
response = workspace.Prompt( PROMPT_OKCANCELLIST, "Select the Picture to view", "Select the Picture you want to view." , "", item.Values )
Else
response = uidoc.document.PicturesFileName(0)
End If
REM Open the picture.
If response <> "" Then
tempVal = workflowdoc.PictureViewer(0) + " """ + Cstr(response) + """"
result = Shell(tempVal, 1)
End If
End Sub
Subject: RE: Getting the filepath of an object embedded as a link in a rich text field
Tim,
Thanks a lot for your help with this.
I will have a go with your code and see if it does the trick for our system.
Someone else told me that I would probably have to use a C-API call to get the information (which would probably be well outside my current skillset.)
So it would be great if your code can get the filepath.
Thanks again,
Richard.