Question : Dispaying and image which attached in a document as a jpeg file

Hi,

I need to display an image file stored in the document when the document is opened. Now, users need to double click on it then select View or Open in order to display. It also displays the image in another tab. But the users do not have much time. They need to see images at the same time opening the document with just one click. And images should be stored as jpeg file in documents because they will be exported to an XML tool later.
Any solution would  be appreciated...

Best Regards


Answer : Dispaying and image which attached in a document as a jpeg file

OK, added are sub and function, used together with Sub importPhoto.
Sub Click is fired under button "Import image". It uses Sub importPhoto, added earlier.
Function  getFilePath displays actual file selection dialog and returns full image path.

Code is not very polished, because it is taken off context, but it will work.

If you want to see added image in document after adding it, then it is need to close and re-open document, otherwise the Rich Text content will be not visible even if the image is imported successfully.
Closing and re-opening can be done by the same code.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
Sub Click(Source As Button)
	
	Dim uiws As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	
	Set uidoc = uiws.CurrentDocument
	Set doc = uidoc.Document
	
	If Not uidoc.EditMode Then
		uidoc.EditMode = True
	End If
	
 
	Dim sess As New NotesSession
	Dim imagePath As String
	Dim filters As String
	filters = "JPG images|*.jpg|All files|*.*"
	imagePath = getFilePath("c:/", "Get picture file",filters)
	
	If imagePath = "" Then
		Print "No picture selected"
		Exit Sub
	End If
	' Function importPhoto assumes, that folder path is marked as "/"
	Dim temp As String
	
	temp = Replace(imagePath, "\", "/")
	
	' NB! Document will be saved in function importPhoto
	Call importPhoto(doc, temp, sess)
	
End Sub
 
' --- get file path 
 
Function getFilePath(dirName As String, dialogTitle As String, filters As String) As String
	' open file path dialog and return file path
	' input: file directory
	' output: file path
	
 
	Dim ws As New NotesUIWorkspace
	Dim fileName As Variant
	
	getFilePath = "" ' seed function return with emtpy string
	
	fileName = ws.OpenFileDialog( True, dialogTitle, filters, dirName)
	If Not(Isempty(fileName)) Then
		getFilePath = fileName(0)
	End If
	
End Function
Random Solutions  
 
programming4us programming4us